Home  >  Article  >  Web Front-end  >  CSS grid elements

CSS grid elements

PHPz
PHPzforward
2023-09-14 08:25:02725browse

CSS 网格元素

The grid element in CSS has a parent element and a child element. Here is an example of creating a grid using 6 elements.

Example

Live Demonstration

<!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>

The above is the detailed content of CSS grid elements. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete