我的本地css样式表中的.navbar
样式并不会覆盖自举预设的样式。
尝试更改导航栏颜色并消除它与内容之间的差距,但似乎无法做到。
我已将本地css文件放在head标签内的bootstrap下面,并修复了我遇到的字体覆盖问题,但它似乎并没有让我改变其他内容。
.bg {
background-image: url(https://s14.postimg.org/whuuxncgh/pexels-photo-247295_16-9.jpg);
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
color: #FFF;
/* Center text vertically in background image*/
display: flex;
flex-direction: column;
justify-content: center;
}

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Pinyon+Script" rel="stylesheet">
<title>Dulce Figueiras - Makeup</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Local css file -->
<link rel="stylesheet" href="css/style.css">
<!-- Custom styles for this template -->
<style type="text/css">
body {
padding-top: 5rem;
}
.starter-template {
padding: 3rem 1.5rem;
text-align: center;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a class="navbar-brand" href="#">Dulce Figueiras</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">About <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Casamentos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Formações</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Testemunhos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Tabela de Preços</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contactos</a>
</li>
<!--
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
-->
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<div class="container-fluid bg" id="landingPage">
<div class="container text-center">
<h1>Dulce Figueiras</h1>
<h3>Makeup Artist</h3>
</div>
</div>
&#13;
答案 0 :(得分:0)
尝试在bootstrap.css之后导入你的css样式文件!
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/your.css" rel="stylesheet">
答案 1 :(得分:0)
您必须使用比框架使用的更多特定选择器。例如。 .navbar
使用nav.navbar
编辑:在您的情况下,.bg-dark
班级会覆盖红色背景,请将其从此处移除:
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
到
<nav class="navbar navbar-expand-md navbar-dark fixed-top">
见下文:
nav.navbar {
margin-bottom: 0;
background-color: red;
font-size: 1.4em;
font-family: 'Pinyon Script', cursive;
}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css?family=Pinyon+Script" rel="stylesheet">
<title>Dulce Figueiras - Makeup</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Local css file -->
<link rel="stylesheet" href="css/style.css">
<!-- Custom styles for this template -->
<style type="text/css">
body {
padding-top: 5rem;
}
.starter-template {
padding: 3rem 1.5rem;
text-align: center;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-md navbar-dark fixed-top">
<a class="navbar-brand" href="#">Dulce Figueiras</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">About <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Casamentos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Formações</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Testemunhos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Tabela de Preços</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contactos</a>
</li>
<!--
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
-->
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</div>
</nav>
<div class="container-fluid bg" id="landingPage">
<div class="container text-center">
<h1>Dulce Figueiras</h1>
<h3>Makeup Artist</h3>
</div>
</div>