【发布时间】:2018-06-02 18:05:32
【问题描述】:
我在 Chrome(macOS 上的 v67)中遇到了 background-position: fixed 的一个非常奇怪的错误,当我滚动时背景图像实际上向上移动,而不是 fixed。
这是问题的代码:https://codepen.io/alexismo/pen/xzwmRE 这是它的 GIF:https://gfycat.com/PolishedHarshAfricangroundhornbill
页面内容的结构如下
<body>
<div class="background-image"></div>
<div class="rest-of-the-site"></div>
</body>
.background-image {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-position: center;
background-size: cover;
background-attachment: fixed;
z-index: -1;
}
【问题讨论】:
标签: html css background-position