Html Twitter Bootstrap 3:如何获得垂直导航栏?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19205858/
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
Twitter Bootstrap 3: How to get vertical navbar?
提问by daydreamer
回答by koala_dev
The default nav
class in Bootstrap 3 has a vertical layout (no borders though), also .nav-pills
still support the stackable layout, but if you want the "old" look you can always just add the styles from the previous version to your CSS (plus a small fix):
nav
Bootstrap 3 中的默认类具有垂直布局(尽管没有边框),也.nav-pills
仍然支持可堆叠布局,但是如果您想要“旧”外观,您可以随时将以前版本的样式添加到您的 CSS(加上一个小的使固定):
.nav-stacked > li {
float: none;
}
.nav-stacked > li > a {
margin-right: 0;
}
.nav-tabs.nav-stacked {
border-bottom: 0;
}
/*Fix to remove space between li's*/
.nav-tabs.nav-stacked>li+li {
margin-top: 0;
}
.nav-tabs.nav-stacked > li > a {
border: 1px solid #ddd;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.nav-tabs.nav-stacked > li:first-child > a {
-webkit-border-top-right-radius: 4px;
-moz-border-radius-topright: 4px;
border-top-right-radius: 4px;
-webkit-border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
border-top-left-radius: 4px;
}
.nav-tabs.nav-stacked > li:last-child > a {
-webkit-border-bottom-right-radius: 4px;
-moz-border-radius-bottomright: 4px;
border-bottom-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-bottomleft: 4px;
border-bottom-left-radius: 4px;
}
.nav-tabs.nav-stacked > li > a:hover,
.nav-tabs.nav-stacked > li > a:focus {
border-color: #ddd;
z-index: 2;
}
回答by oezi
bootstrap 3.0 still contains a nav-stacked
-class. if it's mising in your copy, just get the latest versionor add this to your css-file:
bootstrap 3.0 仍然包含一个nav-stacked
-class。如果它在您的副本中丢失,只需获取最新版本或将其添加到您的 css 文件中:
.nav-stacked > li {
float: none;
}
.nav-stacked > li + li {
margin-top: 2px;
margin-left: 0;
}