CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <style> /* ============== Grid Area ============== */ .grid-container { display: grid; grid-template-columns: auto auto auto auto; grid-gap: 5px; background: #333; } .grid-container .grid-item:first-child { grid-area: 2 / 1 / span 2 / span 3; border: 2px solid #333; background: #bdd8f5; display: flex; justify-content: center; align-items: center; } .grid-item:not(:first-child) { position: relative; background: #97ff99; text-align: center; padding: 10px; height: 50px; line-height: 50px; } /* ============== Grid Area ============== */ </style> </head> <body> <h1 class="heading">Grid Area</h1> <p class="description">We can greate a grid area using the <code>grid-area</code> CSS property. The grid are spans several rows and columns, and its position is also changed as seen below.</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 class="grid-item">7</div> </div> </body> </html>