First look at the code and effect↓ <style> .main { outline: 1px solid; display: flex; justify-content: space-between; flex-wrap: wrap; } .main>div { width: 100px; height: 100px; margin-bottom: 10px; background-color: lightgreen; } </style> <body> <div class="main"> <div>1</div> <div>2</div> <div>3</div> <div>4</div> <div>5</div> <div>6</div> <div>7</div> <div>8</div> </div> </body> You can see that the last div is not in the middle, but at the end. Because we set justify-content to space-between, it means that both sides are attached At this time, we can set a pseudo element for the outermost div, and the width should be the same as the width of the inner div. Just two lines of css are enough .main:after { content: ""; width: 100px; } Now look at the effect In fact, the principle is that the last pseudo-element squeezes him over. Even if there are 9 of them, it doesn't matter, because its height is 0, see the picture below↓ This is the end of this article on how to solve the problem of left alignment of the last line of flex layout space-between. For more information about left alignment of flex layout space-between, 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! |
<<: Teach you how to use docker-maven-plugin to automate deployment
>>: JavaScript Advanced Custom Exception
By default, /etc/default/docker configuration wil...
Table of contents 1. Introduction to computed 1.1...
Table of contents Preface Scope 1. What is scope?...
1. KVM virtual machine migration method and issue...
Docker is becoming more and more popular. It can ...
Introduction The Docker community has created man...
Background: I want to install a SAP ECC server an...
Table of contents 1. Short circuit judgment 2. Op...
Table of contents Preface 1. Introduction to one-...
Docker is an open source project that provides an...
Here we introduce the knowledge about form elemen...
In some scenarios, we want to assign multiple IPs...
Environment: init_worker_by_lua, set_by_lua, rewr...
illustrate When you install the system yourself, ...
Placing a search box in the top menu bar is a com...