Implementation of Grid common layout

Implementation of Grid common layout

No gaps on both sides, gaps between each column

width: 100%;  
display: grid;  
grid-template-columns: repeat(4,1fr);  
justify-items: stretch;  
grid-gap: 1px;

Property introduction: The justify-items property sets the horizontal position of the cell content (left, center, and right), and align-items property sets the vertical position of the cell content (top, center, and bottom).

  • start: Align the starting edge of the cell.
  • end: Aligns to the end edge of the cell.
  • center: The cell is centered inside.
  • stretch: stretch to fill the entire width of the cell (default value).

Property introduction: After the container specifies the grid layout, it then needs to be divided into rows and columns. grid-template-columns property defines the width of each column, and grid-template-rows property defines the height of each row. repeat(4,1fr) means repetition. The first parameter indicates the number of times. There are 4 columns here, which means 4 times. 1rf means the concept of portions. repeat(4,1fr) means it is divided into 4 portions equally.

The effect is as follows:

The gaps between rows and columns are the same, and the vertical direction is prioritized.

.swiper-slide-inner {  
    width: 100%;  
    display: grid;  
    /*Vertical arrangement first*/  
    grid-auto-flow: column;  
    /* Divide into three columns, average score*/  
    /*grid-template-columns: repeat(3, 1fr);*/  
    grid-template-columns: 1fr 1fr 1fr;  
    /* Divide into 2 rows, distribute evenly*/  
    /*grid-template-rows: repeat(2, 1fr);*/  
    grid-template-rows: 1fr 1fr;  
    grid-row-gap: 10px;  
    grid-column-gap: 10px;  
    .card-item {  
        display: flex;  
        flex-wrap: wrap;  
        width: 230px;  
        height: 230px;
    }
}

Property introduction: After dividing the grid, the sub-elements of the container will be automatically placed in each grid in order. The default placement order is "rows first, columns later", that is, fill up the first row first, and then start placing the second row, which is the order of the numbers in the figure below. This order is determined by grid-auto-flow property, and the default value is row , which means "rows first, then columns". You can also set it to column , which means "columns first, rows later".

The effect is as follows:

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  Two examples of using icons in Vue3

>>:  Detailed explanation of MySQL's Seconds_Behind_Master

Recommend

How to connect to virtual machine MySQL using VScode in window environment

1. Virtual Machine Side 1. Find the mysql configu...

HTML table markup tutorial (28): cell border color attribute BORDERCOLOR

To beautify the table, you can set different bord...

Example code of html formatting json

Without further ado, I will post the code for you...

Vue+element+oss realizes front-end fragment upload and breakpoint resume

Pure front-end implementation:切片上傳斷點續傳.斷點續傳needs ...

Five things a good user experience designer should do well (picture and text)

This article is translated from the blog Usability...

How to monitor the running status of docker container shell script

Scenario The company project is deployed in Docke...

How to set the width and height of html table cells

When making web pages, you often encounter the pr...

CSS solution for centering elements with variable width and height

1. Horizontal center Public code: html: <div c...

Vue3 compilation process-source code analysis

Preface: Vue3 has been released for a long time. ...

In-depth understanding of slot-scope in Vue (suitable for beginners)

There are already many articles about slot-scope ...

JavaScript determines whether the browser is IE

As a front-end developer, I can’t avoid IE’s pitf...

Node+Express test server performance

Table of contents 1 Test Environment 1.1 Server H...

Implementation of Redis master-slave cluster based on Docker

Table of contents 1. Pull the Redis image 2. Crea...

Research on the Input Button Function of Type File

<br />When uploading on some websites, a [Se...