这就是我需要的,左侧菜单是240px宽,剩余宽度必须用第二个div填充,整个身体应该可以滚动,请帮忙吗?
+------------+-------------------------------------+
| | |
| | |
| 240px | remaining width |
| | |
| | |
+------------+-------------------------------------+
<body>
<div id="left"></div>
<div id="right"></div>
</body>
答案 0 :(得分:3)
flexbox
section {
display: flex;
}
section div {
border: 1px solid red
}
section div:first-of-type {
flex: 0 240px;
}
section div:last-of-type {
flex: 1
}
&#13;
<section>
<div>1</div>
<div>2</div>
</section>
&#13;
calc()
section {
font-size: 0
}
section div {
border: 1px solid red;
display: inline-flex;
box-sizing:border-box;
font-size: 16px;
}
section div:first-of-type {
width: 240px
}
section div:last-of-type {
width: calc(100% - 240px)
}
&#13;
<section>
<div>1</div>
<div>2</div>
</section>
&#13;
display:table
section {
display: table;
table-layout: fixed;
width:100%
}
section div {
display: table-cell;
border: 1px solid red
}
section div:first-of-type {
width: 240px;
}
section div:last-of-type {
width: 100%;
}
&#13;
<section>
<div>1</div>
<div>2</div>
</section>
&#13;