gpt4 book ai didi

html - 无法更改导航栏的字体颜色

转载 作者:行者123 更新时间:2023-11-28 16:15:29 26 4
gpt4 key购买 nike

我正在尝试将导航栏的背景颜色更改为蓝色,将链接颜色更改为白色。我无法将导航栏上的链接更改为白色。我没有做正确的事。不确定是什么。感谢您的帮助!

 .navbar-default  {
background-color: #2196f3;

}
.navbar a{
color:white;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Home</title>
<link rel="stylesheet" href="css/bootstrap/css/bootstrap.min.css">

<link rel="stylesheet" type="text/css" href="css/bootstrap/css/index.css">
</head>
<body>
<nav class="navbar navbar-fixed-top navbar-default ">
<div class="container-fluid">
<div class="navbar-header">

<a class="navbar-brand" href="#">Home</a>
</div>
<ul class="nav navbar-nav navbar-left">
<li><a href="#">Shop</a></li>
<li><a href="#">Drive</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Zipcode</a></li>
<li><a href="#">Help/FAQ's</a></li>
<li><a href="#">Conatct us</a></li>
</ul>
</div>
</nav>
<script src = "js/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

最佳答案

您的 CSS 规则需要更加具体。参见 Specificity

工作示例:

.navbar.navbar-default {
background-color: #2196f3;
}
.navbar.navbar-default ul > li > a,
.navbar.navbar-default .navbar-brand {
color: white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top navbar-default ">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Home</a>
</div>
<div class="collapse navbar-collapse" id="navbar">
<ul class="nav navbar-nav navbar-left">
<li><a href="#">Shop</a>
</li>
<li><a href="#">Drive</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Zipcode</a>
</li>
<li><a href="#">Help/FAQ's</a>
</li>
<li><a href="#">Conatct us</a>
</li>
</ul>
</div>
</div>
</nav>

关于html - 无法更改导航栏的字体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37605504/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com