嘗試使用旋轉的文本動畫元素的寬度。如果元素旋轉,FireFox中的CSS寬度過渡波動
動畫在Chrome瀏覽器,IE-11,Safari瀏覽器中看起來很順暢,但在FireFox中卻不穩定。
如何使垂直div寬度動畫更加流暢和乾淨?
代碼片段
function animate() {
var e = document.getElementById('rotbox1');
\t if (e.style.width == '120px') e.style.width = '200px'; else e.style.width = '120px';
e = document.getElementById('rotbox2');
\t if (e.style.width == '120px') e.style.width = '200px'; else e.style.width = '120px';
}
animate();
setInterval(animate, 2000);
.wrp-v {
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
-webkit-transform-origin: right;
transform-origin: right;
padding-right: 30px;
position: absolute;
right: 30%;
bottom: 20%;
height: 40px;
}
.wrp-h {
padding-right: 30px;
position: absolute;
right: 30%;
bottom: 20%;
height: 40px;
}
.rotbox {
background: green;
color: white;
display: inline-block;
text-align: center;
height: 40px;
width: 200px;
line-height: 40px;
border-radius: 20px;
font-size: 16px;
-webkit-transition: width 2.0s ease;
transition: width 2.0s ease;
}
<div class="wrp-v">
<div class="rotbox" id="rotbox1">Hello world</div>
</div>
<div class="wrp-h">
<div class="rotbox" id="rotbox2">Hello world</div>
</div>
這是一個已知的bug https://bugzilla.mozilla.org/show_bug.cgi?id=739176 – darham
可以隨時使用jQuery的動畫...... –