css画钟表_纯HTML和CSS绘制的时钟

css

*, *:before, *:after {

box-sizing: border-box;

}

html, body {

height: 100%;

width: 100%;

}

body {

font-size: 100%;

font-family: helvetica;

-webkit-font-smoothing: antialiased;

-moz-osx-font-smoothing: grayscale;

background: linear-gradient(to bottom, #969696 0%, #6e6e6e 100%);

}

#clock {

position: absolute;

top: 0;

left: 0;

right: 0;

bottom: 0;

margin: auto;

width: 21em;

height: 21em;

border-radius: 50%;

background: #eee;

border: 0.2em solid #d0d0d0;

box-shadow: 0 1.2em 0 -1em white, 0 -0.1em 0.3em 0 #fff, 0 0 0 0.6em #e7e7e7, 0 0.6em 1.2em 0 rgba(0, 0, 0, 0.5), inset 0 0.5em 1em 0 rgba(0, 0, 0, 0.3), inset 0 0 8em 0 rgba(0, 0, 0, 0.2);

}

#clock:before {

display: block;

content: "";

position: absolute;

background: #dedede;

left: -2em;

top: -2em;

width: 25em;

height: 25em;

border-radius: 4.6em;

z-index: -1;

box-shadow: inset 0 -0.2em 0.2em 0 rgba(0, 0, 0, 0.2), inset 0 0.2em 2em 0 #fff;

}

#clock:after {

display: block;

content: "";

position: absolute;

height: inherit;

width: inherit;

background: transparent;

top: 0;

left: 0;

border-radius: inherit;

box-shadow: inset 12em 14em 0 -10em rgba(255, 255, 255, 0.25);

z-index: 4;

}

#clock .hour {

position: absolute;

top: 0;

left: 0;

right: 0;

bottom: 0;

margin: auto;

width: 0.5em;

height: 16.4em;

background: transparent;

box-shadow: 0 -1em 0 -0.1em #383838, 0 1em 0 -0.1em #383838;

transform: rotate(30deg);

}

#clock .hour:after, #clock .hour:before {

display: block;

content: "";

position: absolute;

height: inherit;

width: inherit;

background: inherit;

box-shadow: inherit;

backface-visibility: inherit;

}

#clock .hour:before {

transform: rotate(30deg);

}

#clock .hour:after {

transform: rotate(-30deg);

}

#clock .hour:nth-of-type(1) {

transform: rotate(-60deg);

}

#clock .min {

position: absolute;

top: 0;

left: 0;

right: 0;

bottom: 0;

margin: auto;

width: 0.3em;

height: 17em;

background: transparent;

box-shadow: 0 -0.6em 0 -0.1em #383838, 0 0.6em 0 -0.1em #383838;

z-index: -1;

transform: rotate(-54deg);

}

#clock .min:after, #clock .min:before {

display: block;

content: "";

position: absolute;

height: inherit;

width: inherit;

background: inherit;

box-shadow: inherit;

backface-visibility: inherit;

z-index: 0;

}

#clock .min:before {

transform: rotate(6deg);

}

#clock .min:after {

transform: rotate(12deg);

}

#clock .min:nth-child(2) {

transform: rotate(-36deg);

}

#clock .min:nth-child(3) {

transform: rotate(-18deg);

}

#clock .min:nth-child(4) {

transform: rotate(6deg);

}

#clock .min:nth-child(5) {

transform: rotate(24deg);

}

#alarm {

position: absolute;

top: 0;

left: 0;

right: 0;

bottom: 0;

margin: auto;

background: #f8f8f8;

width: 2.6em;

height: 2.6em;

border-radius: 50%;

transform: rotate(-45deg);

box-shadow: 0 0.2em 0.4em 0 rgba(0, 0, 0, 0.1);

}

#alarm:after {

display: block;

content: "";

position: absolute;

width: 0.4em;

height: 4.8em;

top: -4.6em;

background: linear-gradient(to bottom, #f6f6f6 0%, #f8f8f8 100%);

left: 0;

right: 0;

margin: 0 auto;

z-index: -3;

box-shadow: inset 0 1.2em 0 #4ca440, -0.2em -0.2em 0.3em 0 rgba(0, 0, 0, 0.1);

}

#sec {

position: absolute;

top: 0;

left: 0;

right: 0;

bottom: 0;

margin: auto;

background: radial-gradient(ellipse at center, #ffd322 0%, #fbc900 100%);

width: 2em;

height: 2em;

border-radius: 50%;

border: 0.14em solid #fbc900;

z-index: 3;

}

#sec:before, #sec:after {

display: block;

content: "";

position: absolute;

}

#sec:before {

background: #fbc900;

width: 0.8em;

height: 1.5em;

top: 1.8em;

left: 0;

right: 0;

margin: 0 auto;

border-radius: 0 0 2em 2em;

}

#sec:after {

width: 0.18em;

height: 7.6em;

top: -7.6em;

background: #fbc900;

left: 0;

right: 0;

margin: 0 auto;

}

#min,

#hour {

z-index: 2;

position: absolute;

top: 0;

left: 0;

right: 0;

bottom: 0;

margin: auto;

background: #fbc900;

transform-origin: bottom center;

}

#min {

width: 0.6em;

height: 8.6em;

top: -8.6em;

border-radius: 2em 2em 0 0;

box-shadow: inset 0 0 0 0.16em #303030, inset 0 -6em 0 0 #303030, -0.2em -0.2em 0.4em 0 rgba(0, 0, 0, 0.2);

}

#hour {

width: 0.7em;

height: 7em;

top: -7em;

border-radius: 2em 2em 0 0;

box-shadow: inset 0 0 0 0.16em #303030, inset 0 -4.2em 0 0 #303030, -0.2em -0.2em 0.4em 0 rgba(0, 0, 0, 0.2);

}

ol {

position: relative;

height: inherit;

width: inherit;

}

ol li {

counter-increment: customlistcounter;

font-size: 1.4rem;

display: inline-block;

position: absolute;

letter-spacing: -0.1em;

color: #383838;

text-align: center;

}

ol li:before {

content: counter(customlistcounter) "";

}

ol li:nth-child(1), ol li:nth-child(2), ol li:nth-child(4), ol li:nth-child(5), ol li:nth-child(7), ol li:nth-child(8), ol li:nth-child(10), ol li:nth-child(11) {

font-size: 0;

}

ol li:nth-child(3) {

top: 6.95em;

right: 2.4em;

}

ol li:nth-child(9) {

top: 6.95em;

left: 2em;

}

ol li:nth-child(6) {

bottom: 2.1em;

left: 7.06em;

}

ol li:nth-child(12) {

top: 1.9em;

left: 6.78em;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值