我在圖像上使用絕對定位的div。該div有一個不透明度小於1的彩色背景(所以你可以看到圖像)。我的問題是,您可以在圖像下方看到一些空白區域。如何擺脫絕對定位覆蓋圖像下方的空白空間
#zero {
max-width: 450px;
margin: 0 auto;
}
#container {
position: relative;
}
img {
width: 100%;
height: auto;
margin: 0;
padding: 0;
}
#title {
position: absolute;
top: 0;
right: 0 bottom: 0;
left: 0;
height: 100%;
width: 100%;
margin: 0;
color: white;
background-color: red;
opacity: 0.67;
}
<div id="zero">
<div id="container">
<img src="450x300.jpg">
<h2 id="title">Title</h2>
</div>
<p>How to get rid of the white space below the image?</p>
</div>
是的,就是這樣。將img的樣式更改爲顯示:塊和白色空間消失。設計網站多年,現在仍然有麻煩:)。謝謝! –
很好..享受編碼 – coder