0
我在嘗試設置樣式時遇到問題。 #container
應該是viewport
的height
,#caption
應該take as much height as it needs
和img in #image
應該fill the remaining height
(同時保持其縱橫比)。 #container
絕不應該超過視口height
。兩個div動態填充視口高度
<div id="container">
<div id="image">
<img src="my-image.jpg" alt="my-image">
</div>
<div id="caption">
<p>
Some info about this image.<br>
Sometimes this could be two lines.<br>
Maybe even three.
</p>
</div>
</div>
這裏是如何做到這一點工作動態的例子:
有什麼建議?我自己也擺弄了flex和表格,但沒有用,頁面總是以超過視口height
結束。
這是接近,但現在像坐在後面的標題。我需要它動態縮小以不干擾標題。 –
在我的片段中img永遠不會在標題後面,他們是兄弟姐妹 – dippas
圖像是否應該自動縮放以填充其餘高度?它看起來像'img {display:block; margin:auto}'是不足以完成這 –