[英]I am using bootstrap how do I change the color of this navbar by using my css file?
I am using bootstrap and I want to change the color of the navbar but I am unable to do it.我正在使用引导程序,我想更改导航栏的颜色,但我无法做到。
Here is the html code for the nav bar这是导航栏的 html 代码
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">TweetyBird</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Search by Tweet <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Twitter Bot</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">To be added</a>
</li>
</ul>
</div>
</nav>
Here is what I put in my CSS file but the color is still not changing.这是我在 CSS 文件中放入的内容,但颜色仍然没有改变。 What do I need to do to be able to change the color?我需要做什么才能改变颜色?
.navbar{
background-color: darkslategray;
}
You could do that, but you have to add.important to overwrite current value.你可以这样做,但你必须 add.important 覆盖当前值。
.navbar{
background-color: darkslategray!important;
}
or use the solution from HuserB1989(Comments)或使用 HuserB1989 的解决方案(评论)
html .navbar{
background-color: darkslategray;
}
You might have to make your selector more specific, like in the example below:您可能必须使选择器更具体,如下例所示:
.myNavBar {
background-color: red;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.