我的网站上有一个关于 background-size:cover 的小问题 我一直在 Firefox 中测试它,但是当我在谷歌浏览器中加载页面时,我在左边得到 1px 的白色。当我使用 background-position:-1px 时,左边的白边消失了(但后来我把它移到了右边)。有什么办法可以解决这个问题,并且仍然保留封面?
我把它应用到我的 body 上: background:url("images/baggrund.jpg") no-repeat center center fixed;背景大小:覆盖
目前我无法链接到该站点,但希望我描述的足够清楚。
提前致谢
编辑:添加截图,上图来自 firefox,下图来自 Chrome。
最佳答案
试试这个:
background: background:url("images/baggrund.jpg") no-repeat 49% center fixed;
background-size: cover;
在chrome中,当你使用"background-size: cover"时,如果background-image的xpos不小于50%,你就会遇到这个问题。
因此,将 xpos 设置为 49%(或 49.9% 以减少错误)而不是“中心”将解决该问题。
我的英语不好,希望你明白我的意思。
关于html - 背景大小 :cover, 左边 1px 空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14376328/