我正在尝试理解flexbox,但仍有一些问题无法解决。
我已经建立了一个布局,其中左侧列宽为290px,右侧是“内容区域”。
我希望内容区域具有流动性,并且两者的高度均为100%。我已经基本实现了这一点,但如果我在内容区域中填充宽度为100vw的内容,则会使左列缩小。
.right_col {
min-height: 792px;
height: 100%;
margin-left: 0px;
background: #F7F7F7;
display: flex;
padding: 0 !important;
width: 100%;
}
.callout-panel {
background: #fff;
width: 290px;
float: none;
clear: both;
padding: 0 20px;
}
.input-group {
position: relative;
display: table;
border-collapse: separate;
}
.input-group .form-control,
.input-group-addon,
.input-group-btn {
display: table-cell;
}
.input-group .form-control {
position: relative;
z-index: 2;
float: left;
width: 100vw;
margin-bottom: 0;
}
<div class="right_col">
<div class="callout-panel">Left column</div>
<section class="page-inner">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search">
<span class="input-group-btn">
<button class=" btn-search" type="button" ></button>
</span>
</div>
</section>
</div>
input
设置为width: 100vw
。这就是为什么会出现溢出的原因。将input
的长度更改为width: calc(100vw - 290px)
。或者,将input
的父元素设置为flex容器。然后给input
设置flex: 1
。这样可以提供更多的灵活性。 - Michael Benjamin