Home > Article > Web Front-end > CSS grid elements
The grid element in CSS has a parent element and a child element. Here is an example of creating a grid using 6 elements.
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!