Open In App

Primer CSS Grid Nesting

Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, and BEM architecture. It is highly reusable and flexible. It is created with GitHub’s design system.

Primer CSS Grid Nesting is used to put the grid inside another grid. We can put infinite grids within the columns because the column’s width is in percentages. In this article, we will discuss Primer CSS Grid Nesting.



Primer CSS Grid Nesting Classes:

Syntax:



<div class="clearfix">
  <div class="col-* float-left">
    <div class="clearfix">
      <div class="col-* float-left">
        <div class="border">
           ...
        </div>
      </div>
    </div>
  </div>
</div>

Example 1: The following example demonstrates the Primer CSS Grid Nesting.




<!DOCTYPE html>
<html>
  
<head>
    <title> Primer CSS Grid Nesting </title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" />
</head>
  
<body>
    <div class="text-center">
        <h1 class="color-fg-success"> GeeksforGeeks </h1>
        <h3> Primer CSS Grid Nesting </h3>
    </div> <br> <br>
  
    <div class="clearfix">
        <div class="col-4 float-left">
            <div class="border">
                GeeksforGeeks
            </div>
        </div>
        <div class="col-8 float-left">
            <div class="clearfix">
                <div class="col-12 float-left">
                    <div class="col-4 float-left">
                        <div class="border">
                            GFG Nested 1
                        </div>
                    </div>
                    <div class="col-4 float-left">
                        <div class="border">
                            GFG Nested 2
                        </div>
                    </div>
                    <div class="col-4 float-left">
                        <div class="border">
                            GFG Nested 3
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
  
</html>

Output:

Primer CSS Grid Nesting

Example 2: The following example demonstrates the Primer CSS Grid Nesting.




<!DOCTYPE html>
<html>
  
<head>
    <title> Primer CSS Grid Nesting </title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" />
</head>
  
<body>
    <div class="text-center">
        <h1 class="color-fg-success"> GeeksforGeeks </h1>
        <h3> Primer CSS Grid Nesting </h3>
    </div> <br> <br>
  
    <div class="clearfix">
        <div class="col-4 float-left">
            <div class="border">
                GeeksforGeeks
            </div>
        </div>
        <div class="col-8 float-left">
            <div class="clearfix">
                <div class="col-12 float-left">
                    <div class="col-4 float-left">
                        <div class="border">
                            GFG Nested 1
                        </div>
                    </div>
                    <div class="col-4 float-left">
                        <div class="border">
                            GFG Nested 2
                        </div>
                    </div>
                    <div class="col-4 float-left">
                        <div class="border">
                            GFG Nested 3
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div> <br>
  
    <div class="clearfix">
        <div class="col-6 float-right">
            <div class="border">
                GeeksforGeeks
            </div>
        </div>
        <div class="col-6 float-right">
            <div class="col-4 float-left">
                <div class="border">
                    GFG Nest 1
                </div>
            </div>
            <div class="col-8 float-left">
                <div class="border">
                    GFG Nest 2
                </div>
            </div>
        </div>
    </div>
</body>
  
</html>

Output:

Primer CSS Grid Nesting

Reference: https://primer.style/css/utilities/grid#nesting


Article Tags :