CSS 背景颜色更改 Bootstrap
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19356687/
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
Background colour change Bootstrap
提问by Andi Wilkinson
totally rookie question I know, but I am trying to change the background colour in bootstrap
我知道完全是新手问题,但我正在尝试更改引导程序中的背景颜色
i change using
我改变使用
body{background:#fff;}
which works, i can see the change at the bottom of the page, but the whole page and it's entire width is still white
哪个有效,我可以看到页面底部的变化,但整个页面及其整个宽度仍然是白色的
within my page all I then have is
在我的页面中,我所拥有的就是
<div class="container">
<div class="row">
i have changed the body of container and row respectively but its not those. also tried changing the colour of .wrap as inpection shows its contained in that too, but nothing changes the full background and Im a little stumped as to what is blocking it. - Ive not written any actual code yet, its just the standard install and a roots theme.
我已经分别更改了容器和行的主体,但不是那些。还尝试更改 .wrap 的颜色,因为检查显示它也包含在其中,但没有任何改变整个背景,我对阻止它的东西有点困惑。- 我还没有编写任何实际代码,它只是标准安装和根主题。
anyone know what is going on here? i know it will be something stupid.
有谁知道这里发生了什么?我知道这会很愚蠢。
Code is here
代码在这里
<div class="wrap" role="document">
<div class="content row">
<div class="main col-sm-12" role="main">
<div class="page-header">...</div>
<section class="container">
<div class="row">
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
</div><!-- end row -->
</section>
</div><!-- /.main -->
</div><!-- /.content -->
none of these have any background colours applied to them.
这些都没有应用任何背景颜色。
采纳答案by Chris Pickford
You should look into using LESS - if you haven't come across it before it essentially allows you to use variables in CSS. It's very handy.
您应该考虑使用 LESS - 如果您在它本质上允许您在 CSS 中使用变量之前还没有遇到过它。它非常方便。
Anyway, you could always use the customisation options when downloading bootstrap to configure the background colour.
无论如何,您可以在下载引导程序时始终使用自定义选项来配置背景颜色。
Have a look here: http://getbootstrap.com/customize/
回答by Gerald Schneider
With every modern browser you can check easily where the active style comes from.
使用每个现代浏览器,您都可以轻松检查活动样式的来源。
Here is an example using the Chrome developer tools:
以下是使用 Chrome 开发人员工具的示例:
Select the tag you want to investigate, open the computed style and expand the property you need. You'll see every instance where the property is affected and which are overriden by something else.
选择您要调查的标签,打开计算样式并展开您需要的属性。您将看到属性受到影响以及被其他内容覆盖的每个实例。
IE and Firefox have similar tools.
IE 和 Firefox 有类似的工具。
Also, keep in mind that the order of used Stylesheet matters.
另外,请记住,使用的样式表的顺序很重要。
回答by Darshak Malvi
Try this
尝试这个
body {
background-color: #your color code;
}
回答by Andi Wilkinson
I deleted the roots theme and bootstrap. added it again, added the couple of changes I had made previously, (enqued stylesheet)
我删除了 root 主题和引导程序。再次添加,添加了我之前所做的一些更改,(enqued 样式表)
then I changed the backkground of the body again. now it works.
然后我再次改变了身体的背景。现在它起作用了。
i havent a clue why it didn't before, I didnt add any colours anywhere else, I had only just started modifying it. - buggy perhaps?
我不知道为什么以前没有,我没有在其他任何地方添加任何颜色,我才刚刚开始修改它。- 也许是越野车?
but my answer to this is - maybe I broke my theme inadvertently.
但我对此的回答是 - 也许我无意中打破了我的主题。