When using So how do you make the last line left-aligned? Several existing solutions
In the case of pseudo-classes, if the last element is full, there will be a placeholder, the grid will have compatibility issues, and we don’t want to add new tags. Left alignment for each row with a fixed number of columns Since the number of columns is fixed, we can calculate Assuming that each row has only three columns of elements, Assuming the element width is .list1 li:last-child:nth-child(3n + 2) { margin-right: calc((100% - $width) / 2); } Similarly, in the case of one row and four columns, we need to handle two cases: the last element is in the second column and the last element is in the third column. .list2 li:last-child:nth-child(4n + 2) { margin-right: calc((100% - $width) / 3 * 2); } .list2 li:last-child:nth-child(4n + 3) { margin-right: calc((100% - $width) / 3 * 1); } Click here to view the demo code Left alignment for each row with an unfixed number of columns I think the best solution is to use grid. There are a lot of them on the Internet, so I won’t discuss them here. 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. |
<<: 9 great JavaScript framework scripts for drawing charts on the web
>>: 3 ways to add links to HTML select tags
Preface Project requirements: Install the Docker ...
1. Indexes do not store null values More precisel...
1. Command Introduction bzip2 is used to compress...
TypeScript Bundling webpack integration Usually, ...
Configure the accelerator for the Docker daemon S...
Preface Recently, a problem occurred in the test ...
1. Location regular expression Let's take a l...
Cancel the icon 1 in front of ul li Clear Value 1 ...
This article example shares the specific code of ...
To see the effect directly, a right-click menu ha...
I remember that a few years ago, there was an int...
sort Sort the contents of a text file Usage: sort...
Table of contents Vue.js 1. Register global guard...
Table of contents 1. World Map 1. Install openlay...
We all know that Apache can easily set rewrites f...