Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 hidden-xs makes row narrower

I'm experimenting with Bootstrap 3 responsive grids and am trying to make a column disappear from a row when the screen size is small. I can get the column to disappear but the whole row seems to get narrower as a result.

Here's my code that is giving me grief:

<div class="container">  <div class="row">   <div class="col-xs-4 col-sm-2 col-md-1" align="center">    Col1   </div>   <div class="col-xs-4 col-sm-2" align="center">    Col2   </div>   <div class="col-xs-12 hidden-xs col-sm-6 col-md-5" align="center">    Col3   </div>   <div class="col-xs-12 hidden-xs col-sm-12 hidden-sm col-md-3 " align="center">    Col4   </div>   <div class="col-xs-4 col-sm-2 col-md-1" align="center">    Col5   </div>  </div> </div> 

The columns Col4 and then Col3 disappear as the screen gets smaller but the row gets narrower at each removal (when compared to a header row row that doesn't change). I don't get why as I've made sure all the blocks add up to a width of 12 for each stage of the process. I though that maybe the col-xs-12 was the problem but removing this stops the column being removed at all and puts the removed column in with Col5!

I'm obviously missing 'something' but I can't find anything anywhere to help me - hopefully I will find enlightenment here.

like image 611
branty1970 Avatar asked Nov 14 '13 20:11

branty1970


People also ask

What is Col-Xs in Bootstrap?

Grid Classes: The bootstrap-3 grid system has four classes, which are mentioned below: col-xs This class is used for devices with extra-small screen sizes, such as phones, whose width is less than 768px ( <768px).

What does Col MD 5 class means?

col-md- stands for column medium ≥ 992px. col-xs- stands for column extra small ≥ 768px. The pixel numbers are the breakpoints, so for example col-xs is targeting the element when the window is smaller than 768px(likely mobile devices)...

What does COL auto class mean?

If you use col class the columns will be of equal width. If you use col-auto the width of the column will be the width of the contents in the column. You can even use a combination of both, like below. In this case the first column width will be equal to the contents of that column.

What is D grid in Bootstrap?

"D-" is kind of utilities for Bootstrap that effect on Display directly and help you to have Grid Layout. In Css we call that "Display".


1 Answers

How does it work if you only are using visible-md at Col4 instead? Do you use the -lg at all? If not this might work.

<div class="container">     <div class="row">         <div class="col-xs-4 col-sm-2 col-md-1" align="center">             Col1         </div>         <div class="col-xs-4 col-sm-2" align="center">             Col2         </div>         <div class="hidden-xs col-sm-6 col-md-5" align="center">             Col3         </div>         <div class="visible-md col-md-3 " align="center">             Col4         </div>         <div class="col-xs-4 col-sm-2 col-md-1" align="center">             Col5         </div>     </div> </div> 
like image 109
Jimmie Johansson Avatar answered Oct 08 '22 00:10

Jimmie Johansson