Home
CSS
CSS Grid Item
Tryit: Re-arrange the order on small devices
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> .grid-container { display: grid; grid-template-columns: auto auto auto; gap: 10px; background-color: dodgerblue; padding: 10px; } .grid-container > div { background-color: #f1f1f1; color:#000; padding: 10px; font-size: 30px; text-align: center; } @media only screen and (max-width: 500px) { .item1 {grid-area: 1 / span 3;} .item2 {grid-area: 3 / 3;} .item3 {grid-area: 2 / 1;} .item4 {grid-area: 2 / 2 / span 2;} .item5 {grid-area: 3 / 1;} .item6 {grid-area: 2 / 3;} } </style> </head> <body> <h1>Re-arrange the Order on Small Devices</h1> <p>Resize the window to 500 pixels see the effect.</p> <div class="grid-container"> <div class="item1">1</div> <div class="item2">2</div> <div class="item3">3</div> <div class="item4">4</div> <div class="item5">5</div> <div class="item6">6</div> </div> </body> </html>