body {
background-color:#333;
margin:0;
padding:0;
}
.container {
width:500px;
height:500px;
position:relative;
}
.container > div {
position:absolute;
left:50%;
top:50%;
transform:translate(-50%,-50%);
box-sizing:border-box;
border-radius:50%;
}
.month {
width:500px;
height:500px;
border:20px solid #eea2a4;
}
.date {
width:400px;
height:400px;
border:20px solid #ad6598;
}
.hour {
width:300px;
height:300px;
border:20px solid #2177b8;
}
.minute {
width:200px;
height:200px;
border:20px solid #68b88e;
}
.second {
width:100px;
height:100px;
border:20px solid #fcc515;
}
.left,.right {
width:calc(50% + 20px);
height:calc(100% + 40px);
position:absolute;
top:-20px;
overflow:hidden;
}
.left {
left:-20px;
}
.right {
right:-20px;
}
.cir {
width:200%;
height:100%;
border-radius:50%;
box-sizing:border-box;
transform:rotate(-45deg);
color:#fff;
line-height:0;
}
.left .cir {
border-left:20px solid #333;
border-top:20px solid #333;
border-right:20px solid transparent;
border-bottom:20px solid transparent;
text-align:left;
}
.right .cir {
position:relative;
left:-100%;
border-left:20px solid transparent;
border-top:20px solid transparent;
border-right:20px solid #333;
border-bottom:20px solid #333;
text-align:right;
}
.text {
width:20px;
height:calc(50% + 20px);
color:#fff;
position:absolute;
left:50%;
margin-left:-10px;
top:-20px;
box-sizing:border-box;
transform-origin:bottom;
}
container下的子元素div分别为5个圆环的载体。
以类名为second的元素举例。
second元素设置border形成圆环,并填充颜色。
second下面分两个子元素,left和right各占second的一半,分左右两边。
left和right中各有一个cir元素用来画环,环的颜色和背景色一致,cir的大小和位置要和second重合,正好盖住second。
随时间变化,right里面的cir旋转,露出下方的second的圆环。
时间过半的时候,right里面的cir圆环隐藏,旋转left里面的cir的圆环,更大程度上露出second的圆环。
left和right要设置overflow:hidden属性,这样left和right里面的cir旋转的时候,超出部分隐藏,不会再次盖住second的部分。