【发布时间】:2017-06-12 04:27:52
【问题描述】:
我需要一个两列布局,就像一个表格,我不知道其中的列有多宽。
我需要右栏与其内容一样宽(无自动换行),左栏占用剩余空间,如果没有可用空间则进行自动换行。
右栏没问题,如果内容需要,左 div mainInfos 放在它上面。
我希望列并排。我该怎么做才能达到这个结果?
容器具有固定宽度。我不想使用 jquery。
#post {
overflow: hidden;
width: 400px;
border: solid 1px;
}
#post .mainInfos {
overflow: hidden;
}
#post .details {
float: right;
}
<div id="post">
<div class="mainInfos">really really long content that should be wrapped and should be all at the left of "small content", on the same line</div>
<div class="details">small content</div>
</div>
【问题讨论】:
-
按照下面的答案,使用 Flexbox。如果你以前没有遇到过。除了文档 (css-tricks.com/snippets/css/a-guide-to-flexbox) 是一个很好的资源
标签: html css flexbox alignment