简体   繁体   English

使用Bootstrap时如何改变身体的颜色?

[英]How can I change the color of my body when using Bootstrap?

I'm trying out programming Bootstrap and when I was going to change the color of my body using simply: 我正在尝试对Bootstrap进行编程,当我要使用以下简单方法更改我的body颜色时:

body {
  background-color: #eba; 
  width: 100%; 
  height: 100%;
}

It didn't work, so my question is how can I style anything when using Bootstrap? 它没有用,所以我的问题是在使用Bootstrap时如何设置样式? I've looked in the developer's tools and found that background-color: #eba; 我查看了开发人员的工具,发现其background-color: #eba; got ignored and replaced by the default Bootstrap body color , why is that? 被忽略并替换为默认的Bootstrap body color ,为什么? Shouldn't the Bootstrap Default body color get ignored instead of mine? 不应忽略Bootstrap Default的body color而不是我的body color吗? (I might have put two questions in one, so forgive me). (我可能将两个问题合而为一,请原谅我)。

Relevant HTML 相关HTML

<body>
    <div class="container">
        <div class="row">
            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <h4>Column 1</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro exercitationem provident explicabo ipsa consequuntur, quidem dolorem perferendis veritatis facilis fugiat deleniti natus quod laboriosam eum incidunt consequatur cumque voluptates. Repellat.
                </p>
            </div>
            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <h4>Column 2</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro exercitationem provident explicabo ipsa consequuntur, quidem dolorem perferendis veritatis facilis fugiat deleniti natus quod laboriosam eum incidunt consequatur cumque voluptates. Repellat.
                </p>
            </div>
            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <h4>Column 3</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro exercitationem provident explicabo ipsa consequuntur, quidem dolorem perferendis veritatis facilis fugiat deleniti natus quod laboriosam eum incidunt consequatur cumque voluptates. Repellat.
                </p>
            </div>
            <div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
                <h4>Column 4</h4>
                <p>
                    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro exercitationem provident explicabo ipsa consequuntur, quidem dolorem perferendis veritatis facilis fugiat deleniti natus quod laboriosam eum incidunt consequatur cumque voluptates. Repellat.
                </p>
            </div>
        </div>
    </div>
</body>
</html>

Relevant CSS 相关CSS

body {
    background-color: #eba;
}

place your custom css after including bootstrap.css or bootstrap.min.css 在包含bootstrap.css或bootstrap.min.css之后放置自定义CSS

or add !important keyword to your css 或在您的CSS中添加!important关键字

<style type="text/css">
body{background: #eba !important;}
</style>

You have to include your custom .css file after bootstrap.css/bootstrap.min.css Or else you can use '!important' to make your change. 您必须在bootstrap.css/bootstrap.min.css之后包含自定义.css文件,否则可以使用'!important'进行更改。

For example : 例如 :

body {
  background-color: #eba !important; 
  width: 100%; 
  height: 100%;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 type=“color” 从输入中选择颜色时如何更改身体的背景 - How do I change the background of my body when picking a color from my input with the type=“color” 在 Ionic/Angular 中使用 ngIf 时,如何根据按钮的值更改按钮的颜色 - How can I change the color of my button based on its value when using ngIf in Ionic/Angular 如何根据活动幻灯片更改正文背景颜色? - How can I change body background color depending on active slide? 如何更改 index.html 中 body 的背景颜色? - How can I change the background color of the body in index.html? 如何更改我的边框颜色<select>元素不影响引导 css 样式? - How can I change the border color on my <select> element without effecting bootstrap css styling? 如何使用 Bootstrap 4 更改下拉菜单活动背景颜色? - How can I change dropdown menu active background color with Bootstrap 4? 如何更改 hover 上的 Bootstrap 5 工具提示背景颜色? - How can I change a Bootstrap 5 tooltip background color on hover? 如何使用按钮更改颜色? - how can i change color using button? 当我对它们进行 hover 时,如何使我的 Material Icons 改变颜色? - How can I make my Material Icons change color when I hover over them? 如何将主体的背景颜色更改为线性渐变颜色 - how can i change background-color of the body to a linear gradient color
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM