CSS Bootstrap 中的白色背景类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21477101/
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
White background class in Bootstrap
提问by Sharpless512
I'm searching for a class that makes the element a white background.
我正在寻找一个使元素成为白色背景的类。
maybe something like .bg-white, I couldn't find it in Bootstrap but maybe its hidden somewhere?
也许像 .bg-white 这样的东西,我在 Bootstrap 中找不到它,但也许它隐藏在某个地方?
采纳答案by Suriteka
Since Bootstrap 4, Bootstrap does have white, light and dark background classes.
从 Bootstrap 4 开始,Bootstrap 确实有白色、浅色和深色背景类。
HTML:
HTML:
<div class="bg-light text-dark">Light background</div>
<div class="bg-dark text-white">Dark background</div>
<div class="bg-white text-dark">White background</div>
Source : Background Color - Bootstrap Docs
回答by Albzi
Bootstrap doesn't have a white background class.
Bootstrap 没有白色背景类。
Create your own:
创建自己的:
.white-bg{
background:#ffffff !important;
}
This can be placed in bootstrap.css
or your own custom stylesheet if you've created one.
bootstrap.css
如果您已经创建了样式表,则可以将其放置在您自己的自定义样式表中。
The only backgrounds there are in bootstrap are:
bootstrap 中唯一的背景是:
.bg-primary
.bg-success
.bg-info
.bg-warning
.bg-danger
Source: Bootstrap website
资料来源:Bootstrap 网站
回答by Shiju K Babu
I haven't seen any style in bootstrap only for white-background. So apply yourself.
我还没有在 bootstrap 中看到任何仅用于白色背景的样式。所以自己申请。
Add a class bg-white
to your html element. Then in apply the background
style.
bg-white
向您的 html 元素添加一个类 。然后在应用background
样式。
.bg-white{
background:#ffffff;
}
Example
例子
<div class="bg-white">
<!-- div contents go here -->
</div>
回答by martynas
You would have to define such class yourself. Put the following in your custom CSS file.
你必须自己定义这样的类。将以下内容放入您的自定义 CSS 文件中。
CSS:
CSS:
.bg-white {
background-color: #ffffff !important;
}
In Bootstrap you have the following pre-defined backgrounds:
在 Bootstrap 中,您有以下预定义的背景:
Bootstrap 3.1.0:
引导程序 3.1.0:
<div class="bg-primary">...</div>
<div class="bg-success">...</div>
<div class="bg-info">...</div>
<div class="bg-warning">...</div>
<div class="bg-danger">...</div>
Bootstrap 3.0.3:
引导程序 3.0.3:
<div class="alert alert-success">...</div>
<div class="alert alert-info">...</div>
<div class="alert alert-warning">...</div>
<div class="alert alert-danger">...</div>