Detailed explanation of two methods to solve a bug in the justify-content: space-between alignment of flex layout

Detailed explanation of two methods to solve a bug in the justify-content: space-between alignment of flex layout

When setting display:flex, justify-content: space-betweend, it will align the child elements to the sides and evenly divide the remaining space.

For example: if you want to put three child elements in one row

Effect:

This seems to be fine and looks good, but if there are not three characters in the next row, there will be problems if there are only two.

This looks particularly disgusting, with a large empty space in the middle. It looks particularly like a bug, rather than the desired effect of aligning one by one with the previous line.

Now to solve this problem, here are two methods:

  • Pseudo-class: after
  • Provide a placeholder element

Pseudo-class solution

Placeholder element solution

Effect

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.

<<:  Web designer is a suitable talent

>>:  Usage instructions for the docker create command

Recommend

Installation and daemon configuration of Redis on Windows and Linux

# Installation daemon configuration for Redis on ...

How to use nginx to access local static resources on Linux server

1. Check whether port 80 is occupied. Generally, ...

JavaScript static scope and dynamic scope explained with examples

Table of contents Preface Static scope vs. dynami...

Summary of js execution context and scope

Table of contents Preface text 1. Concepts relate...

How to view server hardware information in Linux

Hi, everyone; today is Double 12, have you done a...

CSS3 transition to implement notification message carousel

Vue version, copy it to the file and use it <t...

mysql 5.7.23 winx64 decompression version installation tutorial

Detailed installation tutorial of mysql-5.7.23-wi...

Summary of the characteristics of SQL mode in MySQL

Preface The SQL mode affects the SQL syntax that ...

CSS3 new layout: flex detailed explanation

Flex Basic Concepts Flex layout (flex is the abbr...

Linux C log output code template sample code

Preface This article mainly introduces the releva...

Commonly used JavaScript array methods

Table of contents 1. filter() 2. forEach() 3. som...

What do CN2, GIA, CIA, BGP and IPLC mean?

What is CN2 line? CN2 stands for China Telecom Ne...

MySQL8 Installer version graphic tutorial

Installation The required documents are provided ...