Open In App

Primer CSS Grid Centering a Column

Improve
Improve
Like Article
Like
Save
Share
Report

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.

The Grid Centering Column centers the columns within the container. We can center the columns using the mx-auto class.

Primer CSS Grid Centering a Column Class:

  • mx-auto: This class is used to center the columns.

Syntax:

<div class="col-4 mx-auto">
    Content
</div>

Example 1: This example demonstrates the implementation of the Primer CSS Grid Centering a Column to center the text.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title> Primer CSS Grid Centering a Column </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 Centering a Column 
        </h3
    </div>
    <br>
    <div class="col-2 mx-auto border">
        A Computer Science portal for geeks.
    </div>
</body>
</html>


Output:

Primer CSS Grid Centering a Column

Example 2: This example demonstrates the implementation of the Primer CSS Grid Centering a Column to center the image.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title> Primer CSS Grid Centering a Column </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 Centering a Column </h3>
    </div>
    <br>
    <div class="col-2 mx-auto">
        <img src=
             alt="GFG_logo"
    </div>
</body>
</html>


Output:

Primer CSS Grid Centering a Column

Reference: https://primer.style/css/utilities/grid#centering-a-column



Last Updated : 12 Apr, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads