When you need to implement a border whose length is smaller than the length of the container, most people use div nesting in the past. Now you only need to use pseudo-classes to achieve this effect, and it is very convenient to use. In this article, I will introduce to you how to use CSS pseudo-classes to control the border length. Friends who are interested should take a look.
Foreword:
As shown in the figure: When we need to implement a border whose length is smaller than the length of the container, most of us use div nesting in the past. Now you only need to use pseudo-classes to achieve this effect, and it is very convenient to use.
What is written here is the WeChat applet, so the label will be view
, which does not conflict with html.
html:
1 2 3 4 |
|
css:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
|
The above are the basic styles of the page. If you want to control the length of the border, you need to use :after
pseudo-class css:
1 2 3 4 5 6 7 8 9 10 |
|
The last two sentences are about controlling the centering of the border.