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
Table of contents 1. What is Proxy? 2. How to use...
MySQL 8.0.22 installation and configuration metho...
Table of contents Discover: Application of displa...
Table of contents Preface ErrorBoundary Beyond Er...
Table of contents Boolean Type Number Types Strin...
CentOS 8 has been released for a long time. As so...
1. Linux kernel driver module mechanism Static lo...
Previous This is a classic old question. Since a ...
Table of contents Listener watch Format Set up th...
First of all, for security reasons, JavaScript ca...
<br />Previous article: Seven Principles of ...
1. Function Mainly used to preserve component sta...
1 Pull the image from hup docker pull nginx 2 Cre...
Table of contents MySQL Client/Server Protocol If...
Table of contents 1. A simplest server-side examp...