css - 水平居中 bootstrap 3 个选项卡

标签 css twitter-bootstrap twitter-bootstrap-3

我添加了 center-vertically<div class="col-lg-6 col-lg-offset-3">在服务部分,但这似乎不起作用。我还尝试了其他一些方法,但都没有成功。

center-vertically包含:

display: table-cell;
text-align: center;
vertical-align: middle;

查看 live version here (只需转到服务部分查看选项卡)如果您检查选项卡所在的列上的元素,您会在右侧看到一些额外的空间。

最佳答案

parent 应该有:

parent {
  display: table;
}

child :

child {
  display: table-cell;
  vertical-align: middle;
  margin: 0 auto; // if you want horizontal centering too
}

更新

要将您的 UL 在列内水平居中:

<ul class="nav nav-tabs" style="display: inline-block;margin: 0 auto;">

你的 UL 有全宽。 display: inline-block 将对其进行修剪,而 margin: 0 auto 将其置于父元素的中心。

关于css - 水平居中 bootstrap 3 个选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22471245/

相关文章:

javascript - 模拟单选按钮的引导下拉复选框?

html - 悬停 <tr> 会影响表格中的其他 <tr>

html - 如何在 Bootstrap 中调整容器中的内容?

javascript - 我怎样才能让 angular-ui-router 具有空白的 ui-sref 属性?

ios - 如何在mobile safari和ios模拟器中调试?

html - Bootstrap 可折叠面板在添加样式时不起作用

twitter-bootstrap - 需要 Bootstrap 左侧导航示例

Javascript/jQuery 子菜单(固定位置)

html 正文小于其内容

javascript - 吃 bean 游戏 - 建一堵墙挡住他的行动