为什么CSS属性不适用于<nav>
?我们可以不对这些bootstrap标签进行样式设置吗?如果可以,怎么办?
nav{
display: none;
}
<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">
<nav class="navbar bg-dark nav-light shadow">
<h1 style="color:white">hello</h1>
</nav>
答案 0 :(得分:2)
@kukkuz指出,CSS使用specifity来应用样式。因此,只需编辑选择器即可解决问题
nav.navbar {
display: none;
}
<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">
<nav class="navbar bg-dark nav-light shadow">
<h1 style="color:white">hello</h1>
</nav>