Grid example in CSS

HTML

<!DOCTYPE html>
<html>
  <head>
    <title>Grid Layout Example</title>
      <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <h1>Grid Layout Example</h1>
    <div class="grid-container">
     <div class="grid-item"><img src="images/1.jpg"></div>
	  <div class="grid-item"><img src="images/1.jpg"></div>
	   <div class="grid-item"><img src="images/1.jpg"></div>
	    <div class="grid-item"><img src="images/1.jpg"></div>
		 <div class="grid-item"><img src="images/1.jpg"></div>
		  <div class="grid-item"><img src="images/1.jpg"></div>
    </div>
  </body>
</html>

CSS (save as style.css)

 /* Define the grid container */
      .grid-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        grid-gap: 10px;
        padding: 10px;
      }
      
      /* Define the grid items */
      .grid-item {
        background-color: #F1F1F1;
        padding: 10px;
        font-size: 20px;
        text-align: center;
      }
      
      /* Responsive layout - set the grid to one column on small screens */
      @media (max-width: 600px) {
        .grid-container {
          grid-template-columns: 1fr;
        }
      }