0

我已经编写了以下代码,但我根本无法理解为什么我设置为背景的图像不会垂直拉伸以覆盖整个页面。我会很感激你的帮助

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;
}`
4

1 回答 1

0

使用html:after就像<html>在您的标签旁边添加一个孩子<body>,它无效并且浏览器可能无法正确呈现它,最好使用body:after并设置height: 100%它以覆盖您的页面。

于 2018-11-10T07:40:15.480 回答