Owl selector (*+*) solves the margin problem

In order to solve the problem of stacking margins of multiple selectors, or the spacing problem between multiple components, such as lists, navigation, etc., the *+* owl selector is used to solve the problem, as follows:

*+*, the beginning is a universal selector *, + is an adjacent combinator, and the last * is another universal selector. It selects the non-first element on the page that has the same parent. Each element of the sidebar can be equidistantly spaced.

body * + *{
margin-top:1.5em;
}

The above code globally sets the spacing between stacked elements.

The following is a specific demonstration example

https://codepen.io/AllThingsSmitty/pen/gMRvWq https://codepen.io/AllThingsSmitty/pen/gMRvWq CSS professional skills - "CSS professional skills" - BookStack.com · BookStack CSS professional skills to help you improve your CSS skills collection. https://www.bookstack.cn/read/css-protips-zh/css.md Add a URL for other css techniques. The online test code of the following website is easier to use.

https://codepen.io/pen/icon-default.png?t=M0H8https://codepen.io/pen/

Guess you like

Origin blog.csdn.net/lap2004/article/details/122928528