css - Bootstrap : prevent "nav-tabs nav-justified" from stacking on small screen

标签 css tabs twitter-bootstrap-3

我正在使用 Twitter Bootstrap 3,其中有侧边栏和标签。

enter image description here

<div class="col-md-4">
    <div class="side-posts">
        <ul class="nav nav-tabs nav-justified">
          <li class=""><a href="#recent" data-toggle="tab"><span data-icon="&#xe048;"></span> Recent</a></li>
          <li class="active"><a href="#top" data-toggle="tab"><span data-icon="&#xe0b0;"></span> Popular</a></li>
        </ul>

        <div class="tab-content">
        .....
        </div>
    </div>
</div>

当屏幕的宽度变小时,标签会像这样相互堆叠

enter image description here

是否有可能保持原来的样子并阻止这种变化?

最佳答案

我必须编写自己的标签样式才能让它工作。

enter image description here

这是一个live bootply

如果链接被破坏,这里是 css:

/* CSS used here will be applied after bootstrap.css */
body{
    background-color: #f2f2f2; 
}
.container{
    width: 325px;  
}
.side-posts{
    margin-top:15px;
}
.post-tabs{
  padding:0;
  margin-bottom:0;
  list-style-type: none;
  overflow: hidden;
}
.post-tabs li{
    display: inline;
}
.post-tabs a{
    display: block;
    z-index: 1;
    text-decoration: none;
    padding: 10px 15px;
    float:  left;
    width: 50%;
    text-align:center;
    border-bottom: 1px solid #dddddd;
    text-shadow: 1px 1px 0 white;
    transition:color 0.3s ease;
    background: rgba(255,255,255,1);
    background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
    background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,1)), color-stop(47%, rgba(246,246,246,1)), color-stop(100%, rgba(237,237,237,1)));
    background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
    background: -o-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
    background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
    background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed', GradientType=0 );

    color:#3b5998;
}
.post-tabs a:hover{
    color:#e95c40;
}
.post-tabs li.active a{
    border-bottom: 0;
    color: #444444;
    z-index: 2;
}

.post-tabs li.active:first-child a {
    border-right: 1px solid #dddddd;
    box-shadow: inset -3px 0px 3px 0px rgba(0,0,0,0.4);
}
.post-tabs li.active:last-child a{
    border-left: 1px solid #dddddd;
    box-shadow: inset 3px 0px 3px 0px rgba(0,0,0,0.4);
}
.tab-content{
    height:400px;  
    background-color: #dddddd;
}

关于css - Bootstrap : prevent "nav-tabs nav-justified" from stacking on small screen,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25592635/

相关文章:

css - 使列在 Bootstrap 中固定位置

html - 如何固定第一列,其余列水平滚动

android - 如何设计 Android 标签以获得 3d 外观?

html - 如何让内容只显示在某些选项卡上?

删除 mysql 数据的 Javascript 警报在新选项卡中打开

html - 更改页面内容在打印时的位置

jquery - 如何使动态创建的内容在 jQuery 中保持其功能?

asp.net - 手机造型; "Choose File"iOS 6 按钮太小

php - 在 .htaccess 中使用 AddType .css 时浏览器不解释 .css 文件

javascript - 使用 Bootstrap 3 弹出窗口并加载外部 JSON