Reputation: 2415
I want to make a responsive grid that fits the size of a mobile in both landscape and potrait mode.
So I have following components in my div/grid:
So in potrait mode all of them have a same width and are stacked vertically, whereas in landscape mode all of them have a height and are stacked horizontally. Eg:
In Landscape
In Potrait
I am not well versed with css, and have been trying to do this for past two days. Any help will be deeply appreciated.
Upvotes: 1
Views: 77
Reputation: 3547
There is a media-query to check for the orientation of a device:
@media all and (orientation: portrait) { ... }
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries#orientation
You can use this to apply CSS-rules to your elements only if the device is in portrait mode:
@media all and (orientation: portrait) {
.column {
width: 100%;
}
}
Something like this
Upvotes: 1