[英]CSS3 animation makes element with fixed position image stop working
In Google Chrome, when you have two elements, one that has a CSS3 animation and another with a background-image with a fixed position and an absolute positioned parent (important to keep that), the fixed property stops working when the animation is active. 在Google Chrome浏览器中,当您有两个元素时,一个元素具有CSS3动画,另一个元素具有固定位置的背景图像和一个绝对位置的父对象(保持该位置很重要),当动画处于活动状态时,fixed属性将停止工作。
Here is a JSFiddle, open in Chrome, scroll up and down to see the image be fixed, and then hover over the red square to see the fixed property break: 这是一个JSFiddle,在Chrome中打开,向上和向下滚动以查看图像是固定的,然后将鼠标悬停在红色方块上以查看固定属性的中断:
http://jsfiddle.net/keleturner/44mjq/ http://jsfiddle.net/keleturner/44mjq/
<div class="animation">
</div>
<div class="background">
<span></span>
</div>
.animation { display: block; width: 300px; height: 300px; background: red; -webkit-transition: 1.8s -webkit-transform ease; }
.animation:hover { -webkit-transform: scale(1.1, 1.1); transform: scale(1.1, 1.1);}
.background { position: absolute; left:0; top: 300px; display: block; width: 100%; height: 500px; }
.background span { background-attachment: fixed; background-size: cover; background-image: url(http://image.jpg); width: 100%; height: 100%; display: block; }
Any ideas why? 有什么想法吗?
Why not make the body
element have the background? 为什么不让
body
元素具有背景? Demo 演示版
But to answer your question, it's rendering error due to the body
increasing size due to the scale. 但是要回答您的问题,这是渲染错误,这是由于缩放导致
body
尺寸增大所致。 To fix it add -webkit-transform:translateZ(1px);
要解决此问题,请添加
-webkit-transform:translateZ(1px);
to either .animation
or .background
到
.animation
或.background
But your setup is a silly one to have, it can be done in much better ways 但是您的设置很愚蠢,可以用更好的方法完成
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.