css - 固定背景和封面 - Internet Explorer 11

标签 css internet-explorer-11 background-attachment

http://apolytos.com/new/img/test.html

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
    background:url("background.jpg");
    background-repeat:no-repeat;
    background-attachment:fixed;
    background-size: cover;
    background-position:top center;
    margin:0;
}
</style>
</head>
<body>
</body>
</html>

不涵盖 Internet Explorer 11;查看提供的链接。如果我删除 :fixed,它会按预期覆盖,但是 bg 会滚动页面上不需要的内容。 IE 中这两行代码似乎有冲突。

最佳答案

试试这段代码,它应该能正常工作。

html { 
  background: url(images/bg.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

关于css - 固定背景和封面 - Internet Explorer 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21721980/

相关文章:

css - 如果 child 使用 css3 Transform :Scale 烫伤,父容器不会溢出

html - 菜单 css 菜单显示中心而不是左侧

javascript - Promise.all() 使用 Backbone 解决 IE 11

android - 背景附件:固定不能在 android/mobile 上工作

css - 模拟与 SVG 文本填充属性的背景附件修复相同的效果

javascript - 更改伪类 :before css in javascript for TD

html - 编辑来自不同类的类

css - 为什么 IE 在渲染空 SVG 元素时卡住布局?

java - 调试一个非常难以重现的 Java Web 应用程序问题(前端)

html - 这些背景图像如何保持固定状态?