Html “navbar-header”类在 Bootstrap 中有什么作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34689014/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does "navbar-header" class do in Bootstrap?
提问by Sift
I have been using .navbar-header
class of Bootstrap for my navigation bars for quite a while but never bothered to wonder why. I searched online as to why we use it but didn't find any explanation. Can someone explain what is it's purpose?
我一直在使用.navbar-header
Bootstrap 类作为我的导航栏,但从来没有想过为什么。我在网上搜索我们为什么使用它,但没有找到任何解释。有人可以解释它的目的是什么吗?
<nav class="navbar navbar-inverse ">
<div class="container-fluid">
<div class="navbar-header">
<a href="#" class="navbar-brand">
Website Name
</a>
</div>
</div>
</nav>
采纳答案by LOTUSMS
The navbar-header is mostly an architectural class for Bootstrap navbar. It allocates approximately 150px to the left of the navbar to wrap the navbar-brand and allow the brand name or logo to make use of the entire area on click or hover. But the most useful property of the navbar-header is its responsiveness to 100% width on and after 768px (tablet views). This allows the brand to be centered at the top of the viewport which it is a nicety to have to avoid your responsive menu overlapping your brand when it opens. EDIT--> The navbar-brand doesn't respond to 100% width.
导航栏标题主要是 Bootstrap 导航栏的架构类。它在导航栏左侧分配大约 150 像素的空间来包裹导航栏品牌,并允许品牌名称或徽标在单击或悬停时使用整个区域。但是导航栏标题最有用的属性是它对 768 像素(平板电脑视图)及其之后的 100% 宽度的响应能力。这允许品牌在视口的顶部居中,这是一个很好的方式,必须避免您的响应式菜单在打开时与您的品牌重叠。编辑--> 导航栏品牌不响应 100% 宽度。
But you are right, little it's said about this class in the web, because it doesn't per se execute a function. Most people just either leave it alone, replace it, or use it as a hook (parent) class to target the navbar-brand or any other element they wanted to include within.
但是你是对的,关于这个类在网络上的说法很少,因为它本身并不执行函数。大多数人要么不理会它,要么替换它,或者将它用作挂钩(父)类来定位导航栏品牌或他们想要包含的任何其他元素。