Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stacking Bootstrap Columns over each other

I am using Bootstrap v3 to develop my interface.
I use following snippet:

    <div class="row">
        <div class="col-sm-4 col-xs-4">
            <h1>Hello...!</h1>
            <p>Para 1</p>
        </div>
        <div class="col-sm-8 col-xs-8">
            <h1>new div</h1>
            <p>Para 2</p>
        </div>
    </div>

However, when I decrease the size(width) of browser, the columns get smaller and smaller.
I want that, after a certain limit or min-width, the divs must stack over one another instead of getting smaller.

like image 623
Vikas Raturi Avatar asked Nov 07 '13 05:11

Vikas Raturi


People also ask

How do I make all columns the same size in Bootstrap?

Auto Layout Columns In Bootstrap 4, there is an easy way to create equal width columns for all devices: just remove the number from.col- size -* and only use the.col- size class on a specified number of col elements. Bootstrap will recognize how many columns there are, and each column will get the same width.

How do I stack columns in Bootstrap?

Instead for the columns to get stacked over by default just use this <div class="col-md-4"> instead of xs (xtra small) and sm (small size), use medium size as default, bootstrap will do the rest of your work. And another thing, there is also two different size for your columns (4 and 8), the view would be irregular.

How to keep gap between columns in Bootstrap with CSS?

We can keep gap between columns by using normal CSS but here we will use the Bootstrap framework for that. In this article, we will keep a measured gap between columns by the following methods. Using “div” tag: Simply adding a “div” with padding in between two “div” tags gives spacing between the “div”.

How to add the latest image to a bootstrap column?

You just add each of the latest images as the last child of the thumbnail-container div with each image wrapped in the bootstrap column markup i.e you have to add this for every image: This way when columns are stacked side by side (on large devices), the right-most image will be the latest.


2 Answers

Follow this link for exact sizes of columns/grids for xs, and sm, http://getbootstrap.com/css/#grid-example-mixed You are using a custom width functionality by using

   <div class="col-sm-4 col-xs-4" >

This gives custom width based on the device size. Instead for the columns to get stacked over by default just use this

   <div class="col-md-4"> 

instead of xs(xtra small) and sm(small size), use medium size as default, bootstrap will do the rest of your work. And another thing, there is also two different size for your columns(4 and 8), the view would be irregular. And another thing, if you want to continue using custom sizes for columns instead of my method, remember this : xs-4 is different as sm-4

like image 114
Surendra Bobba Avatar answered Jan 11 '23 06:01

Surendra Bobba


In bootstrap-3 "Class prefix" represents as follows:

.col-xs - Extra small devices - Phones (<768px)

.col-sm - Small devices - Tablets (≥768px)

.col-md - Medium devices - Desktops (≥992px)

.col-lg - Large devices Desktops (≥1200px)

In your coding (you are asking for desktop version i think so...) you have to remove class="col-sm-8 col-xs-8" and add class="col-md-8 col-lg-8"

the above code results, div over one another instead of getting smaller as you need.

like image 31
BobDroid Avatar answered Jan 11 '23 07:01

BobDroid