我正在尝试对元素进行简单的“翻转”转换。它在Firefox中工作得很好,但在Chrome中我得到了一个可怕的 Flink 。
在搜索和尝试了许多事情之后,包括将-webkit-backface-visibility: hidden;
添加到转换元素,我找不到修复方法。
有什么想法吗
Here's a fiddle to show what I mean
下面是我使用的代码:
$('#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>
2条答案
按热度按时间rxztt3cl1#
尝试将
-webkit-backface-visibility: hidden;
添加到.passwordStrength #passwordStrength__flipper.flipped
小提琴来了http://jsfiddle.net/4p93v6oj/1/
更新:
新小提琴:http://jsfiddle.net/4p93v6oj/2/
正如下面其他人指出的,第一种解决方案不起作用,因为当背面隐藏时,click事件不会在元素上注册。
我修改了jquery以在外部元素上触发click事件,如下所示:
然后,将背面可见性添加到
.passwordStrength #passwordStrength__flipper
fiei3ece2#
(to重复一遍,因为这是一个类似的问题)
Chrome以同时转换问题而闻名。可能有帮助的一件事是启用硬件加速,例如:will-change:transform;让chrome使用GPU进行渲染的过渡。