Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap column view in portrait and landscape

I am failry new to bootsrap and wanted to ask, is there anyway, that when the device screen is in Portrait to always use "md" size columns, and when it is in landscape to always use "xs" columns?

like image 974
meztli Avatar asked Mar 10 '14 17:03

meztli


People also ask

How do I make column vertical in Bootstrap?

One way to vertically center is to use my-auto . This will center the element within it's flexbox container (The Bootstrap 4 . row is display:flex ). For example, h-100 makes the row full height, and my-auto will vertically center the col-sm-12 column.

How do I change the position of a column in Bootstrap?

We can easily change the order of built-in grid columns with push and pull column classes. The Push and Pull Classes: The push class will move columns to the right while the pull class will move columns to the left.

What is Col lg 2?

col-lg-2: This class is used when the device size is large or greater than 992px and the maximum width of container is 960px and when you want size equal to 2 columns.

What is lg and MD in Bootstrap?

The Bootstrap grid system has four classes: xs (phones), sm (tablets), md (desktops), and lg (larger desktops).


2 Answers

Extend Bootstrap CSS using new or altered media queries. Normally leaving the original bootstrap.css file and extending it with the changes is the best way, or future upgrades will be troublesome. You might only want to recreate the grid classes you want to use, for example:

@media (min-width: 992px) and (orientation:landscape) {
    .col-md-4 {
        // some properties
    }
}

@media (min-width: 992px) and (orientation:portrait) {
    .col-md-4 {
         // redefined
    }
}

As mentioned by Skelly, there is no orientation switch built into Bootstrap itself at this time.

like image 124
jtheman Avatar answered Oct 22 '22 09:10

jtheman


Here is my actual solution, maybe helps someone

@media (orientation: portrait){
   .portrait{
       width: 100%;
   }
   /*div[class^='col-xs'], div[class*='col-xs']{
       width: 100%;
   }*/
}

Two solutions:

1- is to add "portrait" class to any div that you want to see in portrait with width=100%.

2- Uncomment and use the second rule on the media that applies width:100% to any div that have a class name that starts width col-xs

like image 20
Leonardo Cabré Avatar answered Oct 22 '22 08:10

Leonardo Cabré