2并排divs。一个适合内容,另一个扩展全宽

时间:2017-06-17 19:46:23

标签: html css

我想横向布置两个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

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:0)

使用flexflex-grow

div {
display: flex;
width: 500px;
}
.grow {
flex-grow: 1;
background: #eee;
}
<div>
  <span>content</span>
  <span class="grow">grow</span>
</div>