Ami*_*aqi 6 layout twitter-bootstrap-3
以下是我在Bootstrap 3.2中的布局结构:
<div class="container-fluid">
<div class="row">
<div class="col-xs-3">
<!-- I want this column to be fixed. -->
</div>
<div class="col-xs-6">
<!-- I want only this column to be fluid. -->
</div>
<div class="col-xs-3">
<!-- I want this column to be fixed. -->
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
正如您在psuedo-code注释中所看到的,我希望根据屏幕大小,只有中间列是流畅的.
是否有可能以container-fluidBootstrap的形式出现?或者我应该通过其他方式?
列没有固定宽度的"Bootstrap方式".因此,我们可以使用CSS在几个方面做你想做的事情
.row {
display: flex;
}
.fixed-side-column {
width: 250px;
}
.fluid-middle-column {
flex-grow: 1;
}
Run Code Online (Sandbox Code Playgroud)
.row > div {
float:left; /* Could also use display: inline-block. */
}
.fixed-side-column {
width:250px;
}
.fluid-middle-column {
width:calc(100% - 500px);
}
Run Code Online (Sandbox Code Playgroud)
你必须改变一些标记
<div class="container-fluid">
<div class="row">
<div class="fluid-middle-column">
<!-- I want only this column to be fluid. -->
</div>
<div class="fixed-side-column">
<!-- I want this column to be fixed. -->
</div>
<div class="fixed-side-column right">
<!-- I want this column to be fixed. -->
</div>
</div>
</div>
/* CSS */
.fixed-side-column {
width:250px;
float:left;
}
.right {
float:right;
}
.fluid-middle-column {
position:absolute;
z-index:-1;
top:0;
left:0;
width:100%;
padding: 0 250px 0 250px;
}
Run Code Online (Sandbox Code Playgroud)
您需要添加自定义媒体查询来处理屏幕变小时发生的情况.