我目前正在使用Bootstrap 3.3.4。我的桌面导航栏中的内容在某个时间点太长,因此会溢出到下一行。
下面是一张概述我的意思的图片。
您可以看到,当调整浏览器大小时,徽标会将链接推送到新行。
这是我的CSS,它覆盖了一些Bootstrap类,而不仅仅是少量的格式化,例如容器流体的最大宽度:
@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:700|Lusitana|Arimo);
.container-fluid {
width: 75%;
}
.navbar-spacer {
height: 70px;
}
.navbar-header {
padding-top: 10px !important;
padding-bottom: 0px !important;
}
.navbar-nav > li > a {
padding-top: 25px !important;
padding-bottom: 25px !important;
}
.navbar-brand {
padding-top: 10px !important;
padding-bottom: 10px !important;
padding-left: 0px !important;
}
.navbar {
min-height: 70px !important
}
@media all and (max-width: 767px), only screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 767px), only screen and (min--moz-device-pixel-ratio: 2) and (max-width: 767px), only screen and (-o-min-device-pixel-ratio: 2/1) and (max-width: 767px), only screen and (min-device-pixel-ratio: 2) and (max-width: 767px), only screen and (min-resolution: 192dpi) and (max-width: 767px), only screen and (min-resolution: 2dppx) and (max-width: 767px) {@media all and (max-width: 800px), only screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 950px), only screen and (min--moz-device-pixel-ratio: 2) and (max-width: 950px), only screen and (-o-min-device-pixel-ratio: 2/1) and (max-width: 950px), only screen and (min-device-pixel-ratio: 2) and (max-width: 950px), only screen and (min-resolution: 192dpi) and (max-width: 950px), only screen and (min-resolution: 2dppx) and (max-width: 950px) {
.container-fluid {
width: 100%;
}
.navbar-nav > li > a {
padding-top: 15px !important;
padding-bottom: 15px !important;
}
.navbar-header {
height: 70px;
}
}
这是导航栏的HTML / PHP:
<?php
$currentFile = $_SERVER["PHP_SELF"];
$parts = Explode('/', $currentFile);
?>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<div class='navbar-spacer'></div>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="./"><img src='inc/img/UFCULogo.png'></a>
<!-- 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">
<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 <?php if($parts[count($parts) - 1] == "index.php") { echo "class='active'"; } ?>><a href="./"><span class='glyphicon glyphicon-home'></span> Home</a></li>
<li <?php if($parts[count($parts) - 1] == "contact.php") { echo "class='active'"; } ?>><a href="./contact.php"><span class='glyphicon glyphicon-phone-alt'></span> Contact</a></li>
<li <?php if($parts[count($parts) - 1] == "benefits.php" || $parts[count($parts) - 1] == "newmembers.php") { echo "class='active'"; } ?> class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class='glyphicon glyphicon-user'></span> Members <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li <?php if($parts[count($parts) - 1] == "benefits.php") { echo "class='active'"; } ?>><a href="./benefits.php"><span class='glyphicon glyphicon-thumbs-up'></span> Benefits</a></li>
<li class="divider"></li>
<li <?php if($parts[count($parts) - 1] == "newmembers.php") { echo "class='active'"; } ?>><a href="./newmembers.php"><span class='glyphicon glyphicon-plus'></span> New Members</a></li>
</ul>
</li>
<li <?php if($parts[count($parts) - 1] == "staff.php" || $parts[count($parts) - 1] == "map.php" || $parts[count($parts) - 1] == "times.php") { echo "class='active'"; } ?> class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class='glyphicon glyphicon-info-sign'></span> About <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li <?php if($parts[count($parts) - 1] == "staff.php") { echo "class='active'"; } ?>><a href="./staff.php"><span class='glyphicon glyphicon-user'></span> Staff</a></li>
<li class="divider"></li>
<li <?php if($parts[count($parts) - 1] == "map.php") { echo "class='active'"; } ?>><a href="./map.php"><span class='glyphicon glyphicon-map-marker'></span> Location</a></li>
<li class="divider"></li>
<li <?php if($parts[count($parts) - 1] == "times.php") { echo "class='active'"; } ?>><a href="./times.php"><span class='glyphicon glyphicon-time'></span> Opening Times</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
同样,我正在使用Bootstrap 3.3.4,因此我在之前的帖子中找到的建议似乎无法发挥作用。
这是一个JSFiddle:
https://jsfiddle.net/zupu3L6t/
简单地说,我正在寻找解决此问题的建议,最好是以1000px折叠导航栏,还是当内容溢出时,我将如何解决这个问题。
希望我已经包含了必要的信息,如果没有,请通知我,我很乐意提供。
答案 0 :(得分:3)
如果你使用bootstrap 3.3.4,那么,在第4097行,你有以下代码
@media (min-width: 768px) {
.navbar-collapse {
width: auto;
border-top: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.navbar-collapse.collapse {
display: block !important;
height: auto !important;
padding-bottom: 0;
overflow: visible !important;
}
.navbar-collapse.in {
overflow-y: visible;
}
.navbar-fixed-top .navbar-collapse,
.navbar-static-top .navbar-collapse,
.navbar-fixed-bottom .navbar-collapse {
padding-right: 0;
padding-left: 0;
}
}
您所要做的就是更换
@media (min-width: 768px) {
与
@media (min-width: 1000px) {
你将在1000px上有一个折叠导航。告诉我它是否无效。
希望它有所帮助。 +1,如果它。