我可以在带有 overflow-y 的 div 中使用高度百分比:在其中滚动吗? 标记:
<div id="container">
<div class="messages_container">
<ol class="messages">
<li>sample message here</li>
<li>sample message here</li>
<li>sample message here</li>
</ol>
</div>
<div class="reply">
<form>
<fieldset>
<textarea cols="60" rows="1" name="message"></textarea>
<input type="checkbox" checked="checked">
<input type="submit" value="Submit"/>
</fieldset>
</form>
</div>
最佳答案
不使用百分比,而是使用在 stackoverflow thread 中解释的视口(viewport)高度 (vh)我也做了 jsfiddle亲眼看看
所以代替:
display: block;
width: 100%
height: 50%;
overflow: hidden;
overflow-y: auto;
使用:
display: block;
width: 100vh;
height: 50vh;
overflow: hidden;
overflow-y: auto;
关于html - 我可以在 div 中使用 overflow-y : scroll in it? 中的高度百分比吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11500585/