Flex layout achieves fixed number of rows per line + adaptive layout

Flex layout achieves fixed number of rows per line + adaptive layout

This article introduces the flex layout to achieve a fixed number of rows per line + adaptive layout, and shares it with you. The details are as follows:

Effect display

Analysis

 <div class="template" v-for="(item,templateIndex) in 7">
              <div @click="useTemplate()" v-touch:long="(e)=>touchin(groupIndex,templateIndex)">
                <img class="icon" src="../../../assets/home-page/templateIcon.png" alt />
                <div class="templateName">Template name</div>
              </div>
            </div>
// Parent box, set to:
.templateItem {
  width: 100%;
 
  text-align: center;
  display: flex;
  align-content: flex-start;
  flex-flow: row wrap;
}

//Subbox, set to:
 .template {
  flex: 0 0 25%;
  margin-bottom: 20px;
}

Parent box settings:

The sub-box arrangement method is flex-start. The sub-boxes are placed from the starting point, and line breaks are set by flex-flow. If line breaks are not set, the sub-elements will shrink in size to achieve the effect of being placed in one line.

Subbox settings:

Use flex:0 0 25% to set the placement of the child box. The flex property is an abbreviation of flex-grow, flex-shrink, and flex-basis. The default values ​​are 0, 1, and auto. Specify the number of shares of the sub-item

Disassembly explanation: flex:0 0 25% is equal to flex-grow=0 (no enlargement by default) + flex-shrink=0 (no shrinkage) + flex-basis=25% (the project occupies the main axis space)


For an initial understanding of flex layout, you can read our blog: Initial understanding of flex layout

This is the end of this article about how to use flex layout to achieve a fixed number of rows + adaptive layout. For more information about how to use flex layout to achieve a fixed number of rows + adaptive layout, please search previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Detailed graphic explanation of sqlmap injection

>>:  HTML meta viewport attribute description

Recommend

Flash embedded in web pages and IE, FF, Maxthon compatibility issues

After going through a lot of hardships, I searched...

Solve the problem of spring boot + jar packaging deployment tomcat 404 error

1. Spring boot does not support jsp jar package, ...

MySQL 8.0.17 installation and configuration graphic tutorial

This article records the graphic tutorial of MySQ...

5 Commands to Use the Calculator in Linux Command Line

Hello everyone, I am Liang Xu. When using Linux, ...

Detailed explanation of CSS3+JS perfect implementation of magnifying glass mode

About a year ago, I wrote an article: Analysis of...

Remote Desktop Connection between Windows and Linux

When it comes to remote desktop connection to Lin...

Summary of some common configurations and techniques of Nginx

Preface This article lists several common, practi...

Several methods to clear floating (recommended)

1. Add an empty element of the same type, and the...

How to install pip package in Linux

1. Download the pip installation package accordin...

Win2008 Server Security Check Steps Guide (Daily Maintenance Instructions)

The document has been written for a while, but I ...

Detailed explanation of fuser command usage in Linux

describe: fuser can show which program is current...

The difference between mysql outer join and inner join query

The syntax for an outer join is as follows: SELEC...

Detailed explanation of docker entrypoint file

When writing a Dockerfile, include an entrypoint ...

How to deploy Spring Boot using Docker

The development of Docker technology provides a m...