简体   繁体   English

不同标题长度的 Bootstrap Tabs 具有不同的高度

[英]Bootstrap Tabs with different title lengths have different heights

I am using angular-bootstrap tabs as,我使用 angular-bootstrap 标签作为,

<tabset>
  <tab  ng-repeat="tab in tabs" ui-sref="{{tab.state}}">
    <tab-heading  class="navbar-header" style="cursor:pointer;">
        <div class="col-md-1" style="width: 130px;">
          {{tab.title}}
        </div>
    </tab-heading>
  </tab>
</tabset>
<div class="row-fluid"><div class="ui-view-content" ui-view></div></div>

I am facing problems with the highlighted white color for active tab.我遇到了活动选项卡突出显示的白色的问题。 The white color is drawn over smaller height when the tab title is short and longer heights when the tab title is long当Tab标题长时间较短时,当标签标题短且更长的高度时,白色颜色绘制在较小的高度上

在此处输入图片说明 在此处输入图片说明

Angular version is "1.4.1" and angular bootstrap version is "0.12.2" Angular 版本是“1.4.1”,Angular Bootstrap 版本是“0.12.2”

App css:应用程序CSS:

.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
    color: #555555;
    cursor: default;
    background-color:        #ffffff;
    border: 1px solid #dddddd;
    border-bottom-color: transparent;
}

How to ensure that the selected tab heading's white color is of uniform height?如何确保所选标签标题的白色高度一致?

Have you tried using white-space: nowrap ?您是否尝试过使用white-space: nowrap It basically forces the text to not wrap to the next line.它基本上强制文本不换行到下一行。 Very easy to use.非常容易使用。 Here is an example.这是一个例子。

CSS: CSS:

.nav-tabs li, .nav-tabs a {
    white-space:nowrap;
    overflow: hidden;
}

Working Example工作示例

If the above doesn't work, for whatever reason, try setting a max-height .如果上述方法不起作用,无论出于何种原因,请尝试设置max-height

I believe you cannot achieve this in css.我相信你无法在 css 中实现这一点。 You will have to use javascript to find the tab with max height and apply that height to the rest of them.您将必须使用 javascript 来查找具有最大高度的选项卡并将该高度应用于其余选项卡。

Something from this post would help in the script - jQuery Equal Height Divs这篇文章中的一些内容会对脚本有所帮助 - jQuery Equal Height Divs

With Boostrap 5:使用 Boostrap 5:

.nav-tabs {
  align-items: stretch;
}

.nav-tabs .nav-link {
  height: 102%;
}

The height may vary on more complex setups. height可能因更复杂的设置而异。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM