<分区>
<分区>
我想水平放置两个div
parent div width=500px
- left div: shall grow horizontally to fit to contents (not more or less)
- right div: shall grow horizontally and take up all the space to the right edge
我怎样才能做到这一点?
最佳答案
使用 flex
和 flex-grow
div {
display: flex;
width: 500px;
}
.grow {
flex-grow: 1;
background: #eee;
}
<div>
<span>content</span>
<span class="grow">grow</span>
</div>
关于html - 2个并排的div。一个适合内容,另一个扩展全宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44608776/