css布局实现一个手动计数器交互效果
代码语言:html
所属分类:布局界面
代码描述:css布局实现一个手动计数器交互效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=B612+Mono&display=swap'>
<style>
* {
border: 0;
box-sizing: border-box;
margin: 0;
padding: 0;
}
:root {
--transDur: 0.2s;
font-size: calc(16px + (32 - 16)*(100vw - 320px)/(2560 - 320));
}
body, button {
font: 1em/1.5 "B612 Mono", monospace;
}
body, .counter__digit-window {
display: flex;
}
body {
background: #e3e4e8;
display: flex;
height: 100vh;
}
.counter {
margin: auto;
position: relative;
width: 16em;
height: 18.5em;
}
.counter button {
cursor: pointer;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-tap-highlight-color: transparent;
}
.counter button:focus {
outline: transparent;
}
.counter button::-moz-focus-inner {
border: 0;
}
.counter__clip, .counter__clip:before, .counter__clip:after,
.counter__body, .counter__body:before, .counter__body:after,
.counter__clicker-hole,
.counter__clicker, .counter__clicker:before, .counter__clicker:after,
.counter__digit-frame, .counter__digit-frame:before,
.counter__digit-window:before,
.counter__knob, .counter__knob:before {
position: absolute;
}
.counter__clip:before, .counter__clip:after,
.counter__body:before, .counter__body:after,
.counter__clicker:before, .counter__clicker:after,
.counter__digit-frame:before,
.counter__digit-window:before,
.counter__knob:before {
content: "";
display: block;
}
.counter__clip {
top: -1em;
left: -1em;
width: 7em;
height: 9em;
transform: rotate(-2deg);
transform-origin: calc(100% - 0.375em) 0.375em;
}
.counter__clip:before, .counter__clip:after {
background-color: #17181c;
top: 0;
left: 0;
}
.counter__clip:before {
background-image:
radial-gradient(0.25em 10em at 25% 30%,#fff 40%,#fff0 50%),
radial-gradient(0.2em 12em at 70% 20%,#fff 40%,#fff0 50%),
radial-gradient(0.75em 9em at 50% 25%,#8f95a300 40%,#8f95a3 50%);
border-radius: 0.375em;
box-shadow: -0.1em 0 0.2em #454954 inset;
width: 0.75em;
height: 100%;
}
.counter__clip:after {
background-image:
radial-gradient(0.25em 1em at 2.5% 100%,#fff 40%,#fff0 50%),.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0