【发布时间】:2021-09-12 12:57:41
【问题描述】:
我有一个标题,然后是一个包含类似信息行的 div。
当容器中的 div 适合而没有溢出时,它们会很好地对齐。
但是当有更多行并且容器在overflow:auto 上添加滚动条(我希望它这样做)时,行会失去对齐(我的猜测是因为滚动条占用了空间)
请看这里:Rows now unaligned to make space for scroll bar
我将在底部附上我正在使用的代码。 有谁知道我可以使用的解决方法,以便即使溢出并添加垂直滚动条,所有内容也会保持均匀对齐?我正在使用引导程序 4.6。
感谢您的帮助!
<div id="orders" class="summary">
<div class="container-fluid">
<div class="row">
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Order #</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Time</div></div>
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Name</div></div>
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Created By</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Total</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Sale</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Status</div></div>
</div>
</div>
<div class="container-fluid bg-light" style='height:20%; overflow:auto;'>
<div id='orders-container'>
<div class="row">
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Order #</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Time</div></div>
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Name</div></div>
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Created By</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Total</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Sale</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Status</div></div>
</div>
<div class="row">
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Order #</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Time</div></div>
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Name</div></div>
<div class='col-2'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Created By</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Total</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Sale</div></div>
<div class='col-1'><div class="col-12 h2 text-light font-weight-bold text-center bg-dark rounded pb-2 pt-2">Status</div></div>
</div>
【问题讨论】:
标签: html css bootstrap-4