构建引导程序网站时遇到一些问题。 首先,我有PSD,我必须作为一个响应式引导页面,但在弄乱正确的菜单项目时,似乎我做错了什么。 the menu I need
这就是我现在所拥有的: menu I have now
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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="index.html">
<div class="logo">
<img src="img/logo.png" alt="Homepage">
</div>
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#">Find undervisning</a>
<li><a href="#">Om os</a>
<li><a href="#">Blog</a>
</ul>
<div class="divider">
<ul class="nav navbar-nav navbar-right">
<li><button type="button" class="btn btn-default">Support</button></li></br>
<li><button type="button" class="btn btn-default">Mail <span class="badge">5</span></li>
</ul>
</div>
</div>
</div>
所以,问题是:
.navbar-default .navbar-nav li a: hover {
color:#0295d5;
}
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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="index.html">
<div class="logo">
<img src="img/logo.png" alt="Homepage">
</div>
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#">Find undervisning</a>
<li><a href="#">Om os</a>
<li><a href="#">Blog</a>
</ul>
<div class="divider">
<ul class="nav navbar-nav navbar-right">
<li><button type="button" class="btn btn-default">Support</button></li></br>
<li><button type="button" class="btn btn-default">Mail <span class="badge">5</span></li>
</ul>
</div>
</div>
</div>
</div>
基本上,我需要在bootstrap 3中正确地重新创建这个菜单并使其响应。
答案 0 :(得分:0)
您的html中存在许多问题,在课程名称后遗失"
,</br>
在两个ul
之间使用li
无效,且其他。
要查看这些问题,请使用像phpStorm这样的好IDE,或者,您甚至可以将代码粘贴到jsFiddle中,它会指出问题。 T his is a jsFiddle with your current code,看到所有的红色?这些将告诉你哪里有问题。
在你的css中a: hover
应为a:hover
对于每个元素之间的管道使用:
.navbar-fixed-top .navbar-nav.navbar-right li:not(:first-child):before {
content: " | ";
margin-right:10px;
}
对于徽章,如下所示:
.mail .badge.danger {
color: #fff;
background-color: #d9534f;
border-color: #d43f3a;
padding-bottom: 5px;
font-size: 10px;
position: absolute;
padding: 3px 5px;
top: -4px;
right: -8px;
}
<span class="glyphicon glyphicon-envelope mail" aria-hidden="true">
<span class="badge danger">5</span>
</span>
(您需要将整个代码段设为全屏)
.navbar-fixed-top .navbar-nav.navbar-right{
padding-top: 10px;
}
.navbar-default .navbar-nav li a:hover {
color:#0295d5;
}
.navbar-fixed-top .navbar-nav.navbar-right .glyphicon{
font-size:24px;
}
.navbar-fixed-top .navbar-nav.navbar-right li{
padding-left:10px;
padding-right:10px;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
}
.navbar-fixed-top .navbar-nav.navbar-right li:not(:first-child):before {
content: " | ";
margin-right:10px;
}
.mail .badge.danger {
color: #fff;
background-color: #d9534f;
border-color: #d43f3a;
padding-bottom: 5px;
font-size: 10px;
position: absolute;
padding: 3px 5px;
top: -4px;
right: -8px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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="index.html">
<div class="logo">
<img src="img/logo.png" alt="Homepage">
</div>
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#">Find undervisning</a>
<li><a href="#">Om os</a>
<li><a href="#">Blog</a>
</ul>
<div class="divider">
<ul class="nav navbar-nav navbar-right">
<li>
<button type="button" class="btn btn-default">Support</button>
</li>
<li>
<span class="glyphicon glyphicon-envelope mail" aria-hidden="true">
<span class="badge danger">5</span>
</span>
</li>
</ul>
</div>
</div>
</div>
答案 1 :(得分:0)
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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="index.html">
<div class="logo">
<img src="#" alt="Homepage">
</div>
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<button class="btn btn-default" type="button">Button</button>
</li>
<li>
<button class="btn btn-default" type="button">
Messages <span class="badge">4</span>
</button>
</li>
</ul>
</div><!-- /.navbar-collapse -->
I think this code works properly.
www.MatrixHosting.in, Affordable Windows Hosting Plans in India starts from Rs 99/month.