很棒,你利用宝贵的时间来阅读我的问题!
我正试图在悬停时翻转div。一切顺利,但在过渡期间它会闪烁。它几乎看起来像是多次翻转!这破坏了翻转的整体效果。以下是我的代码和小提琴:
小提琴:FIDDLE
对于 CSS :
.rotate {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
transition: all 0.3s;
padding:20px;
background-color: #333;
width: 200px;
text-align: center;
margin: 0 auto;
font-family: sans-serif;
color: #FFFFFF;
border-top: #E9F01D 3px solid;
}
.rotate:hover {
letter-spacing: 5px;
color: #E9F01D;
cursor: pointer;
-ms-transform: rotatex(360deg);
-webkit-transform: rotatex(360deg);
transform: rotatex(360deg);
}
这种闪烁效果是否可以预防?如果是这样,我该怎么做?
提前致谢!
答案 0 :(得分:3)
如评论中所述:
主要问题是:当鼠标悬停在移动(或动画)div上时,您可能只是从元素中取消悬停,因为它会移动到光标下方。
解决方案:将悬停选择器放置在悬停时不会改变其大小的包含元素上:
<强> Example Here 强>
.rotate {
width: 200px; height:80px;
background:green;
}
.rotate .rotate-inner {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
transition: all 0.3s;
padding:20px;
background-color: #333;
text-align: center;
margin: 0 auto;
font-family: sans-serif;
color: white;
border-top: #E9F01D 3px solid;
}
.rotate:hover .rotate-inner {
letter-spacing: 5px;
color: #E9F01D;
cursor: pointer;
-webkit-transform: rotatex(360deg);
-moz-transform: rotatex(360deg);
-ms-transform: rotatex(360deg);
transform: rotatex(360deg);
}
&#13;
<div class="rotate">
<div class="rotate-inner">HOVER ME</div>
</div>
&#13;