我正在尝试更改使用引导程序创建的导航栏的颜色。我已经尝试过在此站点上看到的其他建议,但是它似乎对我不起作用,因此我不确定自己缺少什么。我已经使用!important设置了背景颜色,但这似乎没有任何效果。
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Restaurant</title>
<link rel="stylesheet" href="../css/style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<div id="content">
<div id="header"></div>
<nav class="navbar navbar-default center navbar-expand-md navbar-light bg-light">
<div class="navbar-nav mx-auto">
<a class="nav-item nav-link active" href="#">About <span class="sr-only">(current)</span></a>
<a class="nav-item nav-link" href="#">Menu</a>
<a class="nav-item nav-link" href="#">Contact</a>
</div>
</nav>
</div>
<script src="main.js"></script>
</body>
</html>
CSS:
#header{
background-image: url(../images/askItalian.jpg);
background-size: auto;
background-repeat: no-repeat;
background-position: top center;
background-attachment: fixed;
width: 100%;
height: 100vh;
margin: 0;
display: flex;
justify-content: center;
justify-items: center;
align-items: center;
}
h1{
font-family: Damion;
font-style: italic;
font-weight: bold;
color: white;
}
.navbar{
position: fixed;
height: 3em;
width: 100%;
}
.navbar-default{
background-color: red !important;
}
答案 0 :(得分:0)
从标记中删除“ bg-light”类,它将起作用
答案 1 :(得分:0)
您可以先加载引导程序。因此,这两个元素在中的位置。
或者只是删除的bg-light类,因为该类具有!important