我编写了以下代码,但我根本无法理解为什么我设置为背景的图像不会垂直拉伸。 谢谢您的帮助
html{
height: 100%;
overflow-y: scroll;
}
html:after{
margin-bottom:0;
content : "";
background: url("../images/van1.jpg") no-repeat center center;
background-size:cover;
width: 100vw;
height: 100vh;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
opacity: 0.5;
filter: alpha(opacity=50);
z-index: -1;
}`
答案 0 :(得分:0)
使用html:after
就像在<html>
标签旁边的<body>
内添加一个子元素一样,它无效,浏览器可能无法正确呈现它,最好使用body:after
并设置height: 100%
覆盖您的页面。