将“Animate needle transition”改为“动态指针过渡”,实现方法如下:
HTML:
CSS:
.meter {
position: relative;
width: 200px;
height: 200px;
background-color: #ccc;
border-radius: 100%;
}
.needle {
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 2px;
height: 70px;
background-color: #f66;
border-radius: 2px;
transition: transform 1s ease;
}
.meter:hover .needle {
transform: translateX(-50%) rotate(90deg);
}
这里利用CSS3中的transition和transform属性,实现指针在鼠标悬浮时旋转的效果。