How to disable stacking of bootstrap justified tabs on small screens

后端 未结 9 2133
我寻月下人不归
我寻月下人不归 2020-12-24 06:51

I have seen this post, but being a new user I can\'t comment to ask for clarification.

I\'m using the justified nav tabs in Bootstrap and don\'t want them to stack o

相关标签:
9条回答
  • 2020-12-24 07:52

    There is a really simple way to prevent stacking:

    CSS:

    .nav li {
        display:table-cell !important;
    }
    

    I searched for this and was annoyed by answers involving custom building bootstrap (I use CDN), and LESS (which I don't use)

    This works great for me...

    0 讨论(0)
  • 2020-12-24 07:55

    In addition to james answer if you don't want to limit max-width to 768px you can do:

    @media (min-width: 0px) {
    
      .nav-justified > li {
        display: table-cell;
        width: 1%;
      }
    
    }
    

    Should I avoid using !important in CSS?

    If you prefer to avoid using !important in CSS paste the code after the bootstrap inclusion.

    0 讨论(0)
  • 2020-12-24 07:57

    I've attempted to edit @pjb answer as it's incomplete. But my edit was rejected, twice, as apparently it's 'incorrect'. Although plunker would tend to disagree...

    This is the original that shows that the active tabs bottom border is showing when condensed

    http://plnkr.co/edit/p62KlHnqPjAsK7XR3mLa?p=preview

    And this version, where it's clearly not showing

    http://plnkr.co/edit/BBDW7nIxGh0J6a9vsuZx?p=preview

    @media (max-width: 768px) {
      .nav-justified > li {
        display: table-cell;
        width: 1%;
      }
      .nav-justified > li > a  {
        border-bottom: 1px solid #ffffd !important;
        border-radius: 4px 4px 0 0 !important;
        margin-bottom: 0 !important;
      }
      .nav-tabs.nav-justified > .active > a,
      .nav-tabs.nav-justified > .active > a:hover,
      .nav-tabs.nav-justified > .active > a:focus {
        border-bottom-color: #fff !important;
      }
    }
    
    0 讨论(0)
提交回复
热议问题