引导元素100%宽度 [英] Bootstrap Element 100% Width
问题描述
我想创建100%交替的彩色块。
I want to create alternating 100% colored blocks. An "ideal" situation is illustrated as an attachment, as well as the current situation.
所需的设置:
目前:
我的第一个想法是创建一个div类,给它一个背景颜色,并给它100%的宽度。 / p>
My first idea was to create an div class, give it a background color, and give it 100% width.
.block {
width: 100%;
background: #fff;
}
但是,您可以看到,这显然不起作用。它限制在一个集装箱区域。我尝试关闭容器,也没有工作。
However, you can see that this obviously doesn't work. It's confined to a container area. I tried to close the container and that didn't work either.
推荐答案
容器
类有意不是100%宽度。根据视口的宽度,它是不同的固定宽度。
The container
class is intentionally not 100% width. It is different fixed widths depending on the width of the viewport.
如果要使用屏幕的整个宽度,请使用 .container -fluid
:
If you want to work with the full width of the screen, use .container-fluid
:
Bootstrap 3 :
<body>
<div class="container-fluid">
<div class="row">
<div class="col-lg-6"></div>
<div class="col-lg-6"></div>
</div>
<div class="row">
<div class="col-lg-8"></div>
<div class="col-lg-4"></div>
</div>
<div class="row">
<div class="col-lg-12"></div>
</div>
</div>
</body>
Bootstrap 2:
<body>
<div class="row">
<div class="span6"></div>
<div class="span6"></div>
</div>
<div class="row">
<div class="span8"></div>
<div class="span4"></div>
</div>
<div class="row">
<div class="span12"></div>
</div>
</body>
这篇关于引导元素100%宽度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!