Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable stacking of bootstrap justified tabs on small screens

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 on small screens, since I only have 2 tabs. I would like them to remain side by side, just shrink down to fit the screen. This is what I have:

    <!-- Nav tabs --> <ul class="nav nav-tabs nav-justified" id="myTab">   <li class="active"><a href="#ratings" data-toggle="tab">Ratings</a></li>   <li><a href="#reviews" data-toggle="tab">Reviews</a></li> </ul>  <!-- Tab panes --> <div class="tab-content">   <div class="tab-pane active" id="ratings">This is a rating section</div>   <div class="tab-pane" id="reviews">This is for reviews. There should be some styling here.</div> </div> 

As the related post suggests using media queries, I cannot seem to make that work. I had tried setting the following to target just small screens:

    @media (max-width: 768px) {   .nav-justified > li {display: table-cell;} } 

I'm not sure what I'm doing wrong so any help is greatly appreciated.

like image 303
user2654108 Avatar asked Feb 26 '14 04:02

user2654108


People also ask

How do I highlight a selected tab in Bootstrap?

If you click on any tab, including the currently active one, the visual cue shows up highlighting the tab.

How do I toggle between tabs in Bootstrap?

To make the tabs toggleable, add the data-toggle="tab" attribute to each link. Then add a . tab-pane class with a unique ID for every tab and wrap them inside a <div> element with class . tab-content .

Which of the following Bootstrap styles are used to create a disabled tab in tabs navigation?

Q14 - Which of the following bootstrap styles are used to create a disabled tab in tabs navigation? For each of the . nav classes, if you add the . disabled class, it will create a gray link that also disables the: hover state.

What are nav-pills?

nav class. Bootstrap tabs separate data in the same wrappers but different panes. Pills are components placed in pages to speed up browsing. Also, the first step of adding links inside navbar is to apply <ul> element together with class="navbar-nav".


1 Answers

The problem with some of the other solutions is that the tabs will lose their borders and other design elements. The following media queries more fully ensure the tabs match in both condensed and wider displays:

@media (max-width: 768px) {   .nav-justified > li {     display: table-cell;     width: 1%;   }   .nav-justified > li > a  {     border-bottom: 1px solid #ddd !important;     border-radius: 4px 4px 0 0 !important;     margin-bottom: 0 !important;   } } 
like image 148
pjb Avatar answered Nov 13 '22 08:11

pjb