我在容器中有2列(内联块)(100%宽度).
左侧列必须具有最小宽度,例如200px,宽度:25%.
右侧柱宽:75%
<style>
.outer {
width: 100%;
border: 1px solid black;
}
.left, .right {
display:inline-block;
}
.left {
min-width: 200px;
width: 25%;
background-color: #dcc2c2;
}
.right {
width: 75%;
background-color: #d0dee8;
}
</style>
<div class="outer">
<div class="left">left</div>
<div class="right">right</div>
</div>
Run Code Online (Sandbox Code Playgroud)在调整大小时达到最小宽度之前,列并排放置,这是我想要的,但是一旦最小宽度开始,右列就会落在下一行.
如何使正确的列缩小但不会落在下一行?
j08*_*691 37
添加white-space:nowrap和overflow:hidden到外:
.outer {
width: 100%;
border: 1px solid black;
white-space:nowrap;
overflow:hidden;
}
Run Code Online (Sandbox Code Playgroud)
你可以使用calc(100% - 200px)保留空间来工作!
.right {
width:75%;
max-width:calc(100% - 200px);
background-color: #d0dee8;
}
Run Code Online (Sandbox Code Playgroud)