0
我已在我的div sectionPhotographer
內創建了一個表格,以正確地分隔我的內容。我已對錶格進行了設置,以便每個td
填充div sectionPhotographer
的50%。我想將img放在其中一個單元格中,但是,img並未按我喜歡的方式調整大小。爲什麼我的HTML在我的HTML/CSS表中大小不正確?
.sectionPhotographer {
height: 90%;
background: #00aeef;
overflow: hidden;
}
.sectionPhotographer table {
height: 100%;
width: 100%;
text-align: center;
margin: 0 auto;
}
.sectionPhotographer td {
width: 50%;
}
.sectionPhotographer img {
height: 100%;
}
<div class="sectionPhotographer">
<table>
<tr>
<td>
<img src="https://lorempixel.com/400/100/">
</td>
<td>
<h1>Turn your pictures into profits</h1>
</td>
</tr>
</table>
</div>
當我設置的img
至100%的高度,我希望它填補了td
它在,但確定其大小的方式過大。任何想法爲什麼發生這種情況?
沒有必要把寬度和最大寬度...寬度:100%將迫使其採取全place和max-widh會強制它不會溢出,但如果圖像很小,它可能會小於100% –