我对网络开发相当陌生(相当新的我的意思是我现在正在上课),我有一个风格迥异的网站,我自己的外部样式表链接和所有种类然而,当我试图让我的网站看起来更好时,我决定尝试为我的导航栏设计一些bootstrap设计,并假设我可以将原始样式表中的内容复制并粘贴到bootstrap.css表中并链接,现在我所有的风格都消失了。任何人都可以解释为什么会发生这种情况/如果我只是犯了某种新手的错误?谢谢!
答案 0 :(得分:2)
您必须将自定义样式表放在bootstrap.css下,如此
<!-- Bootstrap Core CSS -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.css" rel="stylesheet">
<!-- custom stylesheet -->
<link href="css/custom.css" rel="stylesheet">
这是因为HTML从上到下读取css文件。总是从一个bootstrap css开始,从那里你必须调整你的css文件。因此,如果您添加了引导程序导航,则必须在自定义css中进行编辑以更改布局。也许你可以添加一些代码来更具体地说明出错了。
对bootstrap.css进行调整的示例:
导航栏的HTML
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" 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>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="index.html">HOME</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">PORTFOLIO<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="Wedding.html">WEDDING</a></li>
<li><a href="Love.html">LOVE</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">ABOUT<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="AboutUs.html">US</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">BLOG<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="NewBlogPage3.html">STORIES</a></li>
<li><a href="Archive.html">ARCHIVE</a></li>
</ul>
</li>
<li><a href="Contact.html">CONTACT</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
自定义CSS调整
/* BOOTSTRAP TWEAKS */
.navbar-default {
background: none;
border: none;
}
.navbar-default .navbar-nav li a {
color: #9c9c9c;
}
.caret {
border-top-color: #9c9c9c;
border-bottom-color: #9c9c9c;
}
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
color: black;
text-decoration: underline #9c9c9c;
background: none;
}
.navbar-default .navbar-nav > .open > a, .navbar-default .navbar-nav > .open > a:hover, .navbar-default .navbar-nav > .open > a:focus {
color: #555555;
background: none;
}
.dropdown-menu {
list-style: none;
background: none;
border: none;
-webkit-box-shadow:none;
box-shadow: none;
}