我正在一個元素上嘗試一個簡單的“翻轉”過渡。它在火狐瀏覽器上運行得很好,但是在chrome瀏覽器上,我得到了一個可怕的閃爍。
在搜索和嘗試了很多東西包括添加-WebKit-back face-visibility:hidden;轉換元素,我找不到解決方法。
有什么想法嗎?
這里有一把小提琴來說明我的意思
下面是我使用的代碼:
$('#passwordStrength__flipper').click(function() {
$(this).toggleClass('flipped'); // for testing, click the element
});
.passwordStrength {
clear: both;
width: 99%;
position: relative;
padding-bottom: 0px;
height: 240px;
/* set viewing perspective */
-webkit-perspective: 800px;
-moz-perspective: 800px;
-ms-perspective: 800px;
-o-perspective: 800px;
perspective: 800px;
}
.passwordStrength #passwordStrength__flipper {
width: 100%;
height: 200px;
position: absolute;
background-color: #EAEAEA;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
box-sizing: border-box;
-webkit-transition: -webkit-transform 1s;
-moz-transition: -moz-transform 1s;
-ms-transition: -ms-transform 1s;
-o-transition: -o-transform 1s;
transition: transform 1s;
-webkit-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.passwordStrength #passwordStrength__flipper.flipped {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.passwordStrength #passwordStrength__flipper figure {
display: block;
height: 100%;
width: 100%;
position: absolute;
margin: 0;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
}
.passwordStrength #passwordStrength__flipper .passwordStrength__criteriaHolder {
display: block;
padding: 6px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
box-sizing: border-box;
}
.passwordStrength #passwordStrength__flipper .passwordStrength__criteriaHolder #passwordStrength__suggestions {
width: 100%;
margin-top: 8px;
color: #999;
position: relative;
}
.passwordStrength #passwordStrength__flipper .passwordStrength--success {
height: 100%;
width: 100%;
background: #00C2A2;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
box-sizing: border-box;
color: #fff;
text-align: center;
font-size: 16px;
padding: 14px 30px;
line-height: 26px;
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
`
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="passwordStrength" id="password_popup_inline">
<div id="passwordStrength__flipper">
<figure class="passwordStrength__criteriaHolder">Click me...</figure>
<figure class="passwordStrength--success">...then click me</figure>
</div>
</div>
嘗試添加-WebKit-back face-visibility:hidden;敬。密碼強度#密碼強度_ _ flipper.flipped
小提琴在這里:http://jsfiddle.net/4p93v6oj/1/
更新:
新提琴:http://jsfiddle.net/4p93v6oj/2/
正如下面其他人指出的,第一種解決方案不起作用,因為當背面被隱藏時,單擊事件不會在元素上注冊。
我修改了jquery來觸發外部元素上的click事件,如下所示:
$('.passwordStrength').click(function () {
$('#passwordStrength__flipper').toggleClass('flipped');
});
然后,添加了背面可見性。密碼強度#密碼強度__flipper
(在此重復,因為這是一個類似的問題)
眾所周知,Chrome在同步過渡方面存在問題。一件可能有幫助的事情是啟用硬件加速,例如,將改變:轉換;讓chrome us GPU進行渲染過渡。
.smooth-transition {
transition: all 0.3s ease-out;
will-change: transform;
}