我希望有两个并排的div,并且只为一个div定义宽度。
然后,另一个div将自适应父容器。我该怎么做?
HTML代码:
<div class="parent">
<div class="first"></div>
<div class="last"></div>
</div>
CSS:
.parent {
width: 100%;
}
.parent .first {
width: 300px;
float: left;
background-color: red;
}
.parent .last {
width: auto;
float: right;
background-color: blue;
}
谢谢。
display: inline
添加到子 div。 - Cody Guldner