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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:09:23  来源:igfitidea点击:

Twitter Bootstrap 3: How to get vertical navbar?

htmlcsstwitter-bootstraptwitter-bootstrap-3

提问by daydreamer

Seems like it was supported in v2.3.2in form of class .nav-stacked

似乎在v2.3.2中以类的形式支持.nav-stacked

<ul class="nav nav-tabs nav-stacked">
  ...
</ul>

Is there a way to do that in version 3.0.0?

有没有办法在版本中做到这一点3.0.0

回答by koala_dev

The default navclass in Bootstrap 3 has a vertical layout (no borders though), also .nav-pillsstill 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):

navBootstrap 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;
}