[英]why image not stretching verticlly
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%
这样它可以覆盖您的页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.