Navbar品牌名称在一条线上运作良好,但当它突破两行以上时,品牌名称从中殿区域出来。
所以我想让这个品牌名称留在导航栏区域,或者以小屏幕尺寸隐藏它。
请参阅下面的图片链接....
Brand name getting outside from nav area
`<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!--responsive menu button -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!--menu name-->
<a class="navbar-brand" href="#">Taibunnesa Khanom Academy Degree College</a>
</div>
<!-- main menu items -->
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<!--droopdown -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>`
答案 0 :(得分:0)
将您的html更新为此(添加自定义类)
<a class="navbar-brand custom-brand" href="#">Taibunnesa Khanom Academy Degree College</a>
将此添加到您的CSS。
@media (max-width: 480px){
.custom-brand{
float: left;
width: 160px;
overflow: hidden;
clear: left;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
}
}
小提琴:http://codepen.io/hunzaboy/pen/gLWozx
我相信你会喜欢这个:)
答案 1 :(得分:0)
当屏幕宽度达到“768px宽”时,这会将.navbar-brand
的高度设置为auto
。
@media screen and (max-width: 768px){
.navbar-brand{
height: auto !important;
}
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<!--responsive menu button -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!--menu name-->
<a class="navbar-brand" href="#">Taibunnesa Khanom Academy Degree College</a>
</div>
<!-- main menu items -->
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<!--droopdown -->
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
&#13;