【发布时间】:2016-03-19 14:53:11
【问题描述】:
我有这个代码:
div#fond {
background-image: url('https://www.thetileapp.com/images/Purse_Tabletop-46.jpg');
background-size: cover;
height: 100%;
width: 100%;
}
<!DOCTYPE html>
<html>
<body>
<div id="fond">
ABCD
</div>
<br>
<img src="https://www.thetileapp.com/images/Purse_Tabletop-46.jpg" width="100%" />
</body>
</html>
如何使 div 具有与 img 相同的行为,以便 div 的高度适应窗口的宽度。 目前,高度适应 div 内容。
【问题讨论】:
标签: css background-image background-size