I have written the following code and I simply cannot understand why the image I have setted to be on the background doesn't strech vertically to cover the full page . I would appreciate your help
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;
}`
使用html:after
就像在<body>
标记旁边的<html>
添加一个孩子一样,这是无效的,浏览器可能无法正确呈现它,最好使用body:after
并设置height: 100%
这样它可以覆盖您的页面。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.