嗨我有这样的菜单栏
这是我的HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Business Casual Template for Bootstrap</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<!-- Add custom CSS here -->
<link href="css/business-casual.css" rel="stylesheet">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-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">Info Dubai</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li><a href="#"><span><img src="images/todoBtn.png"></span> ToDo</a></li>
<li><a href="#"><span><img src="images/dineBtn.png"></span> Dining</a></li>
<li><a href="#"><span><img src="images/shopBtn.png"></span> Shooping</a></li>
<li><a href="#"><span><img src="images/todoBtn.png"></span> NightLife</a></li>
<li><a href="#"><span><img src="images/fashionBtn.png"></span> Fashion</a></li>
<li><a href="#"><span><img src="images/bodyBtn.png"></span> Body&Mind </a></li>
<li><a href="#"><span><img src="images/eventBtn.png"></span> Events</a></li>
<li><a href="#"><span><img src="images/exclusiveBtn.png"></span> Exclusive</a></li>
<li><a href="#"><span><img src="images/tarvelBtn.png"></span> Travel</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
<!-- /.container -->
<!-- JavaScript -->
<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>
这里是css
hr {
border-color: #999999;
max-width: 400px;
}
.brand,
.address-bar {
display: none;
}
.navbar-brand {
text-transform: uppercase;
letter-spacing: 2px;
font-weight: 900;
}
.navbar-nav {
text-transform: none;
letter-spacing: 0px;
font-weight:bold;
}
.img-full {
min-width: 100%;
}
.brand-name {
font-weight: 700;
font-size: 1.5em;
text-transform: capitalize;
letter-spacing: normal;
}
.tagline-divider {
margin: 15px auto 3px;
border-color: #999999;
max-width: 250px;
}
.box {
background: #fff;
background: rgba(255,255,255,0.9);
margin-bottom: 20px;
padding: 30px 15px;
}
.intro-text {
text-transform: uppercase;
letter-spacing: 1px;
font-size: 1.25em;
font-weight: 400;
}
.img-border {
float: none;
margin: 0 auto 0;
border: #999999 solid 1px;
}
.img-left {
float: none;
margin: 0 auto 0;
}
footer {
background: #fff;
background: rgba(255,255,255,0.9);
}
footer p {
margin: 0;
padding: 50px 0;
}
@media screen and (min-width: 768px) {
.brand {
display: inherit;
font-weight: 700;
font-size: 5em;
line-height: normal;
text-align: center;
margin: 0;
padding: 30px 0 10px;
color: #fff;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.top-divider {
margin-top: 0;
}
.img-left {
float: left;
margin-right: 25px;
}
.address-bar {
display: inherit;
text-align: center;
margin: 0;
padding: 0 0 40px;
font-size: 1.25em;
text-transform: uppercase;
letter-spacing: 3px;
font-weight: 400;
color: #fff;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.navbar {
border-radius: 0;
}
.navbar-header {
display: none;
}
.navbar {
min-height: 0;
}
.navbar-default {
background:#FFF;
background: #323132;
border: none;
}
.nav>li>a {
/*padding: 35px;*/
}
.navbar-nav>li>a {
line-height:normal;
}
.navbar-nav {
float: none;
margin: 0 auto;
display: table;
table-layout: fixed;
font-size: 0.99em;
}
}
@media screen and (min-width: 1200px) {
.box:after {
content: '';
display: table;
clear: both;
}
}
.navbar-default .navbar-nav > li > a {
color:#FFF;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #FFF !important;
background-color: #DD9B26 !important;
}
.navbar-default .navbar-toggle {
border-color: #ddd !important;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background-color: #999 !important;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #CCC !important;
}
.navbar-collapse {
max-height: 340px;
padding-right: 15px;
padding-left: 15px;
overflow-x: visible;
-webkit-overflow-scrolling: touch;
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
background-color:#323132;
}
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border-color: transparent;
}
但我想要这种菜单栏
![在此输入图像说明] [2]
但没有成功。如果有任何身体有想法或技巧,我想制作全宽等空间li
水平菜单栏请与我分享
响应
答案 0 :(得分:0)
我理解你的问题是你想让每个导航链接的宽度相等,并跨越浏览器的整个宽度。如果这是正确的,您可以使用此示例生成等宽导航链接:http://getbootstrap.com/examples/justified-nav/#
要使导航跨越浏览器的整个宽度,您需要将容器更改为容器流体。在上面的示例中,这意味着用<div class="container">
替换<body>
标记下方的<div class="container-fluid">
。
使用你拥有的东西,以便你也可以获得切换效果:
<div class="container">
更改为<div class="container-fluid nav-container">
所以,你的CSS会看起来像这样。请注意,您必须使用字体大小或图像才能使所有菜单项整齐地放在一行上,如果这是您想要的所有屏幕宽度。在我的屏幕上,一些链接开始突破到1228px的下一行!
hr {
border-color: #999999;
max-width: 400px;
}
.brand,
.address-bar {
display: none;
}
.navbar-brand {
text-transform: uppercase;
letter-spacing: 2px;
font-weight: 900;
}
.navbar-nav {
text-transform: none;
letter-spacing: 0px;
font-weight:bold;
}
.img-full {
min-width: 100%;
}
.brand-name {
font-weight: 700;
font-size: 1.5em;
text-transform: capitalize;
letter-spacing: normal;
}
.tagline-divider {
margin: 15px auto 3px;
border-color: #999999;
max-width: 250px;
}
.box {
background: #fff;
background: rgba(255,255,255,0.9);
margin-bottom: 20px;
padding: 30px 15px;
}
.intro-text {
text-transform: uppercase;
letter-spacing: 1px;
font-size: 1.25em;
font-weight: 400;
}
.img-border {
float: none;
margin: 0 auto 0;
border: #999999 solid 1px;
}
.img-left {
float: none;
margin: 0 auto 0;
}
footer {
background: #fff;
background: rgba(255,255,255,0.9);
}
footer p {
margin: 0;
padding: 50px 0;
}
@media screen and (min-width: 768px) {
.nav-container {padding: 0;}
.navbar-nav>li {width: 11.111111%;}
.navbar-nav {width: 100%;}
.navbar-collapse {padding: 0;}
.brand {
display: inherit;
font-weight: 700;
font-size: 5em;
line-height: normal;
text-align: center;
margin: 0;
padding: 30px 0 10px;
color: #fff;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.top-divider {
margin-top: 0;
}
.img-left {
float: left;
margin-right: 25px;
}
.address-bar {
display: inherit;
text-align: center;
margin: 0;
padding: 0 0 40px;
font-size: 1.25em;
text-transform: uppercase;
letter-spacing: 3px;
font-weight: 400;
color: #fff;
text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}
.navbar {
border-radius: 0;
}
.navbar-header {
display: none;
}
.navbar {
min-height: 0;
}
.navbar-default {
background:#FFF;
background: #323132;
border: none;
}
.nav>li>a {
/*padding: 35px;*/
}
.navbar-nav>li>a {
line-height:normal;
}
.navbar-nav {
float: none;
margin: 0 auto;
display: table;
table-layout: fixed;
font-size: 0.99em;
}
}
@media screen and (min-width: 1200px) {
.box:after {
content: '';
display: table;
clear: both;
}
}
.navbar-default .navbar-nav > li > a {
color:#FFF;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus {
color: #FFF !important;
background-color: #DD9B26 !important;
}
.navbar-default .navbar-toggle {
border-color: #ddd !important;
}
.navbar-default .navbar-toggle:hover,
.navbar-default .navbar-toggle:focus {
background-color: #999 !important;
}
.navbar-default .navbar-toggle .icon-bar {
background-color: #CCC !important;
}
.navbar-collapse {
max-height: 340px;
overflow-x: visible;
-webkit-overflow-scrolling: touch;
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
background-color:#323132;
}
.navbar-default .navbar-collapse, .navbar-default .navbar-form {
border-color: transparent;
}