Created
September 30, 2025 21:17
-
-
Save madeinnordeste/9a2fd2c2ee6fee3f90b4f53599e36873 to your computer and use it in GitHub Desktop.
css element positions with breakpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="pt-br"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Layout Responsivo</title> | |
| <style> | |
| * { | |
| box-sizing: border-box; | |
| } | |
| body { | |
| margin: 0; | |
| padding: 20px; | |
| font-family: sans-serif; | |
| } | |
| .container { | |
| display: flex; | |
| flex-wrap: wrap; | |
| } | |
| .rosa { | |
| background-color: #f4cccc; | |
| flex: 3; | |
| padding: 20px; | |
| border: 2px solid #000; | |
| border-radius: 15px; | |
| margin: 5px; | |
| order: 1; | |
| } | |
| .verde { | |
| background-color: #d9ead3; | |
| flex: 1; | |
| padding: 20px; | |
| border: 2px solid #000; | |
| border-radius: 15px; | |
| margin: 5px; | |
| order: 2; | |
| } | |
| .amarelo { | |
| background-color: #fff2b8; | |
| width: 100%; | |
| padding: 20px; | |
| border: 2px solid #000; | |
| border-radius: 15px; | |
| margin: 5px; | |
| order: 3; | |
| } | |
| /* Modo responsivo */ | |
| @media (max-width: 767px) { | |
| .container { | |
| flex-direction: column; | |
| } | |
| .rosa, .verde, .amarelo { | |
| width: 100%; | |
| flex: none; | |
| } | |
| .rosa { | |
| order: 1; | |
| } | |
| .amarelo { | |
| order: 2; | |
| } | |
| .verde { | |
| order: 3; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <div class="rosa">Elemento Rosa</div> | |
| <div class="verde">Elemento Verde</div> | |
| <div class="amarelo">Elemento Amarelo</div> | |
| </div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment