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/