bootstrap 3 nav navbar div 在标志图片下跳转
bootstrap 3 nav navbar div jumps under logo image
这个问题很难描述。所以看看这个 jsFiddle:
http://jsfiddle.net/arodrig0/xfs257hp/2/
当 header 变小时,导航栏会跳到图像徽标下方。
我想制作一个宽度不超过 970px 的容器,并且菜单或徽标会变得更小 or/and 徽标会出现在切换图标之前。
问题出在哪里?
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="./css/bootstrap.css" media="screen" rel="Stylesheet" type="text/css" />
<link href="./css/style_new.css" media="screen" rel="Stylesheet" type="text/css" />
<body>
<header class='container' role='navigation'>
<div class='navbar navbar-header'>
<a class="navbar-brand" id="logo" href="/">
<img alt="Brand" src="/layout/images/logo_new.gif" height="74px" width="237px">
</a>
<button type='button' class='navbar-toggle collapsed' 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>
</div>
<div id="containerNav">
<ul id="test"class='nav navbar-nav navbar-left collapse navbar-collapse'>
<li class="dropdown">
<a href='#' data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li class="bottom"></li>
</ul>
</li>
<li><a href='#' data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a></li>
<li class="dropdown">
<a href="#1" data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">samples<br><span>samples</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
</ul>
</li>
<li>
<a href="#">sample<br><span>sample</span></a>
</li>
<li class="dropdown">
<a href="#" data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
</ul>
</li>
</ul>
</div>
</header>
<div id="carousel" class="row">
</div>
</div> <!-- End Main Container-->
</body>
您的导航菜单宽度太长。所以,当屏幕变小的时候,就没有足够的space和logo挤在同一条线上了。
尝试在列 class "col-sm-4 col-md-3" 和 "col-sm-8 col-md-9" 中添加一个 div 来包裹导航 header 和 containerNav。
http://jsfiddle.net/gnauLypt/1/
<div class="col-sm-4 col-md-3">
<div class="navbar navbar-header">
...
</div>
</div>
<div class="col-sm-8 col-md-9">
<div id="containerNav">
...
</div>
</div>
没有完全理解你的意思,但一种方法可能是...将 col-md-2 col-sm-2 放在 'navbar navbar-header' 上 和 col-md-10 col-sm-10 在 div id 'containerNav' 上。这些是原始链接吗,因为要显示的数量很多。您也可以尝试 width:100%; height:auto; 在 #logo img 上使其宽度在响应式屏幕上灵活。
这个问题很难描述。所以看看这个 jsFiddle:
http://jsfiddle.net/arodrig0/xfs257hp/2/
当 header 变小时,导航栏会跳到图像徽标下方。 我想制作一个宽度不超过 970px 的容器,并且菜单或徽标会变得更小 or/and 徽标会出现在切换图标之前。
问题出在哪里?
<title></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="./css/bootstrap.css" media="screen" rel="Stylesheet" type="text/css" />
<link href="./css/style_new.css" media="screen" rel="Stylesheet" type="text/css" />
<body>
<header class='container' role='navigation'>
<div class='navbar navbar-header'>
<a class="navbar-brand" id="logo" href="/">
<img alt="Brand" src="/layout/images/logo_new.gif" height="74px" width="237px">
</a>
<button type='button' class='navbar-toggle collapsed' 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>
</div>
<div id="containerNav">
<ul id="test"class='nav navbar-nav navbar-left collapse navbar-collapse'>
<li class="dropdown">
<a href='#' data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li class="bottom"></li>
</ul>
</li>
<li><a href='#' data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a></li>
<li class="dropdown">
<a href="#1" data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">samples<br><span>samples</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
</ul>
</li>
<li class="dropdown">
<a href="#" data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
</ul>
</li>
<li>
<a href="#">sample<br><span>sample</span></a>
</li>
<li class="dropdown">
<a href="#" data-target='#' class='dropdown-toggle' data-toggle='dropdown'data-hover="dropdown">sample<br><span>sample</span></a>
<ul class='dropdown-menu' role='menu'>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
<li><a href="#">sample</a></li>
</ul>
</li>
</ul>
</div>
</header>
<div id="carousel" class="row">
</div>
</div> <!-- End Main Container-->
</body>
您的导航菜单宽度太长。所以,当屏幕变小的时候,就没有足够的space和logo挤在同一条线上了。 尝试在列 class "col-sm-4 col-md-3" 和 "col-sm-8 col-md-9" 中添加一个 div 来包裹导航 header 和 containerNav。 http://jsfiddle.net/gnauLypt/1/
<div class="col-sm-4 col-md-3">
<div class="navbar navbar-header">
...
</div>
</div>
<div class="col-sm-8 col-md-9">
<div id="containerNav">
...
</div>
</div>
没有完全理解你的意思,但一种方法可能是...将 col-md-2 col-sm-2 放在 'navbar navbar-header' 上 和 col-md-10 col-sm-10 在 div id 'containerNav' 上。这些是原始链接吗,因为要显示的数量很多。您也可以尝试 width:100%; height:auto; 在 #logo img 上使其宽度在响应式屏幕上灵活。