我有两个这样的元素:
<div class="element"><span></span></div>
元素必须有一个圆角(CSS)并且在悬停时边框必须是虚线(CSS)并旋转,但是span应该是静态的。有什么帮助吗?
@keyframes rotate {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
@-moz-keyframes rotate {
from {
-moz-transform: rotate(0);
}
to {
-moz-transform: rotate(360deg);
}
}
@-webkit-keyframes rotate {
from {
-webkit-transform: rotate(0);
}
to {
-webkit-transform: rotate(360deg);
}
}
.element {
width: 40px;
height: 40px;
background: #ededed;
color: @fff;
}
.element:hover {
animation: rotate 2s infinite linear;
-moz-animation: rotate 2s infinite linear;
-webkit-animation: rotate 2s infinite linear;
}
&#13;
<div class="element"><span>1</span>
</div>
&#13;
答案 0 :(得分:3)
.element {
width: 250px;
height: 250px;
border:3px solid grey;
border-radius:50%;
margin: 25px auto;
line-height: 250px;
text-align: center;
}
.element:hover {
border-style:dashed;
animation: spin 10s infinite linear;
}
.element:hover span {
animation: spin 10s infinite reverse linear;
}
span {
display: inline-block;
}
@keyframes spin {
100% { transform: rotate(1turn); }
}
&#13;
<div class="element"><span>Not Spinning On Hover</span></div>
&#13;
答案 1 :(得分:1)
我相信 this 代码集具有您需要的结果。但是,此方法需要<span>
内的其他<div>
元素。