【问题标题】:background-attachment:fixed bug in Chrome for Retina only背景附件:修复了仅适用于 Retina 的 Chrome 中的错误
【发布时间】:2014-08-15 07:17:53
【问题描述】:

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

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

这里是问题的截图链接:

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

【问题讨论】:

    标签: css google-chrome retina-display background-attachment


    【解决方案1】:

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

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

    【讨论】:

    • 如果您分享了上述代码的哪一部分实际上解决了问题,您的回答将非常有用。不只是回击一个可行的例子,让每个人都去猜测。
    猜你喜欢
    • 1970-01-01
    • 2018-11-21
    • 2014-04-13
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多