如前所述,使用标准的Bootstrap网格系统无法实现这一点。然而,通过一些CSS调整,可以遵循以下“规则”来实现:
首先放置侧边栏并将其向右浮动。
<div class="col-sm-5 pull-right">
..
</div>
col-sm-7
的宽度为自适应,并取消浮动。.float-none {
float: none;
width: auto;
}
最后,col-sm-7
内的任何子DIV都需要使用overflow: auto
...
演示:http://codeply.com/go/njEg31ZG33
据我所知,flexbox 对此无济于事。
content
col-7 和您的sidebar
col-5。content
项目总共达到了400(您的侧边栏的高度)。这意味着从第四个元素开始,您可以将类更改为col-12。var contentItems = $(".content"); // your 'content' items
var sidebar = $(".sidebar");
var contentItemHeight = $(".content").first().height;
var sidebarHeight = $(".sidebar").height;
var smallColumns = sidebarHeight / contentItemHeight; // 4
var $i = 1;
$.each($contents, function(){
if($i <= smallColumns){
// Next to sidebar
$(this).addClass(".col-xs-7");
}else{
// Below sidebar
$(this).addClass(".col-xs-12");
}
})
// Edited to remove accidental switch to PHP
position: relative;z-index:1;
。已修复:https://www.codeply.com/go/njEg31ZG33 - Carol Skelly