在使用background-attachment:fixed时,我发现Chrome仅在视网膜屏幕上渲染背景图像的问题。Firefox和Safari可以正常工作。我还注意到,当我在开发人员工具>控制台>渲染中单击"启用连续页面重新绘制"框时,我可以让它在Chrome中工作。但是,这在启用时也会导致严重的性能问题。当从background-attachment:fixed更改为background-attachment:scroll时,图像呈现得很好,但随后我失去了预期的效果。
对于这个问题有什么建议吗?或者我将不得不瞄准retina设备上的Chrome并取消其功能?
下面是问题的链接和截图:
https://code.google.com/p/chromium/issues/detail?id=366012我有同样的问题,试试这个:
此处演示http://jsfiddle.net/dN4S4/493/
body{
padding: 0;
margin: 0;
}
#main{
width: 100%;
height: auto;
margin: 0;
padding: 0;
}
#fixedElement{
-webkit-transform: translateZ(0);
-webkit-backface-visibility:hidden;
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
margin:auto;
z-index: -1;
display: block;
}
.fullWidthImage{
background: url("http://s.camptocamp.org/uploads/images/1255459227_450187593.jpg") no-repeat center center;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
overflow: hidden;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
position: relative;
}
.bottom{
position: relative;
top: 500px;
width: 100%;
height: 800px;
background-color: purple;
margin: 0;
padding: 0;
}
<div id="main">
<div id="fixedElement">
<div class="fullWidthImage">
</div>
</div>
<div class="bottom">
</div>
</div>