Home
CSS
CSS Flexbox
Flex Responsive
Tryit: Responsive flexbox
Run ❯
Get your
own
website
Result Size:
625 x 534
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <head> <style> * { box-sizing: border-box; } .flex-container { display: flex; flex-wrap: wrap; font-size: 30px; text-align: center; } .flex-item-left { background-color: #f1f1f1; padding: 10px; flex: 50%; } .flex-item-right { background-color: dodgerblue; padding: 10px; flex: 50%; } /* Responsive layout - makes a one column-layout instead of a two-column layout */ @media (max-width: 800px) { .flex-item-right, .flex-item-left { flex: 100%; } } </style> </head> <body> <h1>Responsive Flexbox</h1> <p>In this example, we change the percentage of flex to create different layouts for different screen sizes.</p> <p><b>Resize the browser window to see that the direction changes when the screen size is 800px wide or smaller.</b></p> <div class="flex-container"> <div class="flex-item-left">1</div> <div class="flex-item-right">2</div> </div> </body> </html>