【发布时间】:2016-10-11 05:36:08
【问题描述】:
我在 flexbox 中有 2 个并排的 div。右手边的宽度应该始终相同,我希望左手边的宽度只占剩余空间。但除非我专门设置它的宽度,否则它不会。
所以目前,它设置为 96%,这看起来还不错,直到你真正挤压屏幕 - 然后右手 div 有点缺乏它需要的空间。
我想我可以保持原样,但感觉不对 - 就像必须有一种方式说:
正确的总是一样的;你在左边 - 你得到了剩下的一切
.ar-course-nav {
cursor: pointer;
padding: 8px 12px 8px 12px;
border-radius: 8px;
}
.ar-course-nav:hover {
background-color: rgba(0, 0, 0, 0.1);
}
<br/>
<br/>
<div class="ar-course-nav" style="display:flex; justify-content:space-between;">
<div style="width:96%;">
<div style="overflow:hidden; white-space:nowrap; text-overflow:ellipsis;">
<strong title="Course Name Which is Really Quite Long And Does Go On a Bit But Then When You Think it's Stopped it Keeps on Going for even longer!">
Course Name Which is Really Quite Long And Does Go On a Bit But Then When You Think it's Stopped it Keeps on Going for even longer!
</strong>
</div>
<div style="width:100%; display:flex; justify-content:space-between;">
<div style="color:#555555; margin-right:8px; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;" title="A really really really really really really really really really really really long department name">
A really really really really really really really really really really really long department name
</div>
<div style="color:#555555; text-align:right; white-space:nowrap;">
Created: 21 September 2016
</div>
</div>
</div>
<div style="margin-left:8px;">
<strong>></strong>
</div>
</div>
【问题讨论】:
-
你也可以使用
grid-template-rows/columns