html - '背景附件: fixed' breaks when 'position: absolute' is used on chrome

标签 html css google-chrome

background-attachment: fixed;position: absolute; 结合使用时,视差滚动效果会反转或进入错误的方向。当未应用 position: absolute; 时效果很好。

请参阅此代码笔:https://codepen.io/0xbbadbeef/pen/bKaYQp

.attached-abs {
  width: 100%;
  height: 200px;
  background-image: url('https://thetypewritermovie.files.wordpress.com/2011/06/shaw2.png');
  background-attachment: fixed;
  position: absolute;
}

同样的 CSS 在 Edge 上运行良好,但无法在 Chrome 上运行。

我是否使用了错误的属性或有任何解决方法?

最佳答案

您可以尝试将位置设置为相对position:relative;

希望对你有帮助

干杯!

关于html - '背景附件: fixed' breaks when 'position: absolute' is used on chrome,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50920013/

相关文章:

html - 宽屏幕上的 CSS float 对齐不均匀

c# - 即使使用 @import 也捆绑 css

javascript - AngularJs:-在ng类的三元运算中添加多个条件

sqlite - Chrome 的时间戳是什么格式?

google-chrome - 在不跨步骤共享的云构建步骤中安装 google-chrome(使用卷)

python - 抓取使用 AJAX Post 填充数据的网站

html - 如何使用 "display: table"合并两行,css?

javascript - 尝试将 Codepen 代码复制到本地

html - CSS Tooltip(工具提示显示即使不显示)

javascript - 如何在 Chrome 上请求用户对音频的许可?