CSS Grid Elements


Grid Elements in CSS has parent and child elements. Here’s an example wherein a grid is created with 6 elements.

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <style>
         .container {
            display: grid;
            grid-template-columns: auto auto;
            padding: 20px;
         }
         .ele {
            background-color: orange;
            border: 2px solid gray;
            padding: 25px;
            font-size: 20px;
            text-align: center;
         }
      </style>
   </head>
   <body>
      <h1>Game Board</h1>
      <div class = "container">
         <div class = "ele">1</div>
         <div class = "ele">2</div>
         <div class = "ele">3</div>
         <div class = "ele">4</div>
         <div class = "ele">5</div>
         <div class = "ele">6</div>
      </div>
   </body>
</html>

Updated on: 25-Jun-2020

263 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements