[英]CSS background-image property
這是我的HTML:
<div id="banner" style="background-image: url("img/banner.jpg")">
<img src="img/logo.png" alt="logo" />
</div>
這是我的CSS:
#banner {
width: auto;
height: 100vw;
background: url("/img/banner.jpg");
我希望banner.jpg成為具有完整視口填充的那個div的背景...怎么辦?
添加以下CSS代碼:
#banner{
width: %100;
}
這就是我將如何實現效果https://jsfiddle.net/d5Lptwut/10/
<div id="banner">
<img src="img/logo.png" alt="logo" />
</div>
html, body {
height: 100%;
padding: 0;
margin: 0;
}
#banner {
background: url('/img/banner.jpg') no-repeat center center;
height: 100%;
width: 100%;
background-size: cover;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.