我正在尝试进行布局,其中列是两行的高度。我似乎无法找到以前的答案。
我正在使用Bootstrap 3。
这是代码
<div class="container">
<div style="margin:100px">
<!---spacer-->
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12" id="top-row"></div>
<div>
<div class="col-lg-8 col-md-8 col-sm-12" id="bottom-row"></div>
<div class="row">
<div class="col-lg-4 col-md-4 col-sm 12" id="quote-2-high"></div>
</div>
</div>
<div style="margin:100px">
<!---spacer-->
</div>
</div> <!-- extra closing div ? -->
还有一些CSS
#top-row {
background-color: lime;
height: 250px;
}
#bottom-row {
background-color: pink;
height: 250px;
}
#quote-2-high {
background-color: aqua;
height: 500px;
}
如果它有任何用途,我在这里有一个codepen。 http://codepen.io/steeth/pen/gPVwMK?editors=1100
正如您所见,蓝色列从红色顶部开始,但我想从绿色顶部开始。
答案 0 :(得分:2)
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="row" id="top-row"></div>
<div class="row" id="bottom-row"></div>
</div>
<div class="col-lg-4 col-md-4 col-sm-4" id="quote-2-high"></div>
</div>
</div>
Bootstrap Grid System这是一个非常简单的概念,但我建议您使用此工具,它会对您有所帮助:http://shoelace.io/
答案 1 :(得分:1)
<强> UPADATE:强> 使用此标记,蓝色框将保留为一个框而不是两个分隔框。粉红色的盒子向上移动250px,因此在绿色框下面。
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12" id="top-row"></div>
<div class="col-lg-4 col-md-4 col-sm 12" id="quote-2-high"></div>
<div class="col-lg-8 col-md-8 col-sm-12" id="bottom-row"></div>
</div>
#bottom-row {
background-color: pink;
margin-top: -250px;
height: 250px;
}
您需要使用完全不同的标记。
在每一行中都有列的位置,总计为12,所以你继续在第一行放置8和4,在第二行放置8和4。
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12" id="top-row"></div>
<div class="col-lg-4 col-md-4 col-sm 12" id="quote-2-high"></div>
</div>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-12" id="bottom-row"></div>
<div class="col-lg-4 col-md-4 col-sm 12" id="quote-2-high"></div>
</div>
删除蓝色元素的双倍高度,然后完成:
#top-row {
background-color: lime;
height: 250px;
}
#bottom-row {
background-color: pink;
height: 250px;
}
#quote-2-high {
background-color: aqua;
height: 250px;
}
演示:Codepen