2

在使用 background-attachment:fixed 时,我发现 Chrome 如何仅在视网膜屏幕上呈现背景图像的问题。Firefox 和 Safari 按预期工作。我还注意到,当我单击“开发人员工具”>“控制台”>“渲染”中的“启用连续页面重绘”框时,我可以让它在 Chrome 中工作。但是,这也会在启用时导致严重的性能问题。当图像从背景附件:固定更改为背景附件:滚动时,图像渲染良好,但随后我失去了预期的效果。

关于解决此问题的任何建议?或者我是否必须在视网膜设备上定位 Chrome 并终止该功能?

这是一个带有屏幕截图的问题的链接:

https://code.google.com/p/chromium/issues/detail?id=366012

4

1 回答 1

0

我有同样的问题,试试这个:

在这里演示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>

于 2015-07-21T22:02:41.640 回答