[英]why image not stretching verticlly
我已經編寫了以下代碼,我根本無法理解為什么我設置為背景的圖像不能垂直拉伸以覆蓋整個頁面。 謝謝您的幫助
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.