Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make a grid layout with CSS3
#1
Example:

<!DOCTYPE html>
<html>
<head>
  <title>Grid Layout Example</title>
  <style>
    /* Apply grid layout to the container element */
    .container {
      display: grid;
      grid-template-columns: repeat(3, 100px);
      grid-gap: 10px;
    }
    /* Apply grid items */
    .item {
      width: 100px;
      height: 100px;
      background-color: lightblue;
    }
  </style>
</head>
<body>
  <div class="container">
    <div class="item">1</div>
    <div class="item">2</div>
    <div class="item">3</div>
  </div>
</body>
</html>

Explanation:

CSS Grid Layout is used for creating complex grid-based designs. In this example, the container class is a grid container with the property display: grid. The grid-template-columns property sets the columns to repeat three times with a width of 100 pixels each, and grid-gap adds a 10-pixel gap between grid items. The item class represents the grid items with a width and height of 100 pixels and a light blue background color.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CSS Grid Masonry Layout Qomplainerz 0 446 07-26-2023, 07:54 PM
Last Post: Qomplainerz
  CSS Grid Subgrid Qomplainerz 0 283 07-26-2023, 07:46 PM
Last Post: Qomplainerz
  CSS Grid Auto-fit and Minmax Qomplainerz 0 273 07-26-2023, 07:41 PM
Last Post: Qomplainerz
  Multi-column layout in CSS3 Qomplainerz 0 279 07-26-2023, 07:23 PM
Last Post: Qomplainerz
  How to make a flexbox in CSS3 Qomplainerz 0 214 07-26-2023, 07:02 PM
Last Post: Qomplainerz
  How to make animations with CSS3 Qomplainerz 0 203 07-26-2023, 07:01 PM
Last Post: Qomplainerz
  How to make transitions with CSS3 Qomplainerz 0 223 07-26-2023, 06:59 PM
Last Post: Qomplainerz
  How to make shadows with CSS3 Qomplainerz 0 193 07-26-2023, 06:58 PM
Last Post: Qomplainerz
  How to make gradients with CSS3 Qomplainerz 0 192 07-26-2023, 06:57 PM
Last Post: Qomplainerz
  How to make rounded corners with CSS3 Qomplainerz 0 171 07-26-2023, 06:51 PM
Last Post: Qomplainerz

Forum Jump:


Users browsing this thread: 1 Guest(s)