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}'是不足以完成这 –