CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <style> /* ============== Grid Responsive ============== */ .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); grid-gap: 5px; background-color: #333; } @media screen and (max-width: 968px) { .grid-container { grid-template-columns: repeat(2, 1fr); } } @media screen and (max-width: 680px) { .grid-container { grid-template-columns: 1fr; } } .grid-item { position: relative; background: #97ff99; text-align: center; border: 1px solid #333; padding: 10px; height: 50px; line-height: 50px; } /* ============== Grid Responsive ============== */ </style> </head> <body> <h1 class="heading">Grid Responsive</h1> <p class="description">We can make responsive grid layouts using the @media queries. Resize the window to experience the responsiveness.</p> <div class="grid-container"> <div class="grid-item">1</div> <div class="grid-item">2</div> <div class="grid-item">3</div> <div class="grid-item">4</div> <div class="grid-item">5</div> <div class="grid-item">6</div> </div> </body> </html>