Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to dynamically adapt the layout by using only CSS

Tags:

css

Depending by the size of the app interface, I need to adapt dynamically the layout by using only CSS. It will be possible?

If the width of my app is 500px, I'd like to display the 3 containers in this way:

            | A   B |  // width 500px
            |   C   |

If the width of my app is 750px, I'd like to display the 3 containers in this way:

            |  A  B  C  | // width 750px

Here is the example.

By clicking on the button "change app size" you can change the size of the container.

like image 630
antonjs Avatar asked Dec 21 '22 08:12

antonjs


1 Answers

With CSS media queries:

<link type="text/css" rel="stylesheet" href="style.css" />    
<link rel="stylesheet" media="screen and (max-width: 500px)" href="css/mobile-500.css" />
<link rel="stylesheet" media="screen and (max-width: 750px)" href="css/mobile-750.css" />
like image 87
Blender Avatar answered Jan 05 '23 06:01

Blender