Implementation idea of ​​left alignment of the last row of flex box layout

Implementation idea of ​​left alignment of the last row of flex box layout

Using flex layout, if it is a nine-square grid, it can be divided equally, as shown in the figure

insert image description here

If we only need eight pieces, as shown in the figure

insert image description here

But if we want the last block to be left-aligned and arranged in sequence, we need to add a pseudo-element after to the parent of the element, as shown in the figure

<div class="box">
	<ul>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
		<li></li>
	</ul>
</div>
ul{
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
}
ul:after{
	content: "";
	width: 32%;
}
ul li{
	width: 32%;
	height: 10vh;
	margin-bottom: 1vh;
	background: #2fbaff;
} 

insert image description here

This concludes this article about how to implement left-alignment of the last line in flex box layout. For more flex layout content, please search previous articles on 123WORDPRESS.COM or continue browsing the following related articles. I hope you will support 123WORDPRESS.COM in the future!

<<:  SQL implementation LeetCode (176. Second highest salary)

>>:  Vue implements simple calculator function

Recommend

How to install grafana and add influxdb monitoring under Linux

Install grafana. The official website provides an...

How to install and deploy MySQL 8.0 under CentOS8

MySQL 8 official version 8.0.11 has been released...

Facebook's nearly perfect redesign of all Internet services

<br />Original source: http://www.a-xuan.cn/...

Vue implements automatic jump to login page when token expires

The project was tested these days, and the tester...

Explore VMware ESXI CLI common commands

Table of contents 【Common commands】 [Summary of c...

React realizes secondary linkage (left and right linkage)

This article shares the specific code of React to...

Summary of the use of CSS scope (style splitting)

1. Use of CSS scope (style division) In Vue, make...

MySql 5.6.36 64-bit green version installation graphic tutorial

There are many articles about MySQL installation ...

Change the MySQL database engine to InnoDB

PS: I use PHPStudy2016 here 1. Stop MySQL during ...

MySQL 5.7.19 installation and configuration method graphic tutorial (win10)

Detailed tutorial on downloading and installing M...

Detailed process of implementing the 2048 mini game in WeChat applet

Rendering Example Code Today we are going to use ...

How to skip errors in mysql master-slave replication

1. Traditional binlog master-slave replication, s...