Html 如何使用 twitter bootstrap 格式化背景颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16347668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to format background color using twitter bootstrap?
提问by sharataka
I am playing with the styles on the website here: http://www.grabapper.com
我在这里玩网站上的样式:http: //www.grabapper.com
I am trying to include background-color #2ba6cb
on the hero unit. When I include:
我试图#2ba6cb
在英雄单位上包含背景颜色。当我包括:
<div class="row" style ='background-color: #2ba6cb;'>
The color doesn't go all the way to the edge of the page. How do I get the background color to go to the edge of the page?
颜色不会一直到达页面的边缘。如何让背景颜色转到页面边缘?
采纳答案by cortex
Move your row before <div class="container marketing">
and wrap it with a new container, because current container width is 1170px (not 100%):
之前移动你的行<div class="container marketing">
并用一个新容器包装它,因为当前容器宽度是 1170px(不是 100%):
<div class='hero'>
<div class="row">
...
</div>
</div>
CSS:
CSS:
.hero {
background-color: #2ba6cb;
padding: 0 90px;
}
回答by Khandad Niazi
Bootstrap default "contextual backgrounds" helper classes to change the background color:
Bootstrap 默认的“上下文背景”帮助类来改变背景颜色:
.bg-primary
.bg-default
.bg-info
.bg-warning
.bg-danger
If you need set custom background color then, you can write your own custom classes in style.css( a custom css file) example below
如果您需要设置自定义背景颜色,则可以在下面的 style.css(自定义 css 文件)示例中编写自己的自定义类
.bg-pink
{
background-color: #CE6F9E;
}
回答by Benjamin Udink ten Cate
Just add a div around the container
so it looks like:
只需在周围添加一个 div container
,它看起来像:
<div style="background: red;">
<div class="container marketing">
<h2 style="padding-top: 60px;"></h2>
</div>
</div>