1. Merge the margins of sibling elements The effect is as follows: (the spacing between the two is 100px, not 150px) 2. Merge the outer margins of nested elements For two nested elements, if there is no content in the parent element or the content is behind the child element and there is no top padding and border, the top margin of the parent element will be merged with the top margin of the child element, and the value will be the largest top margin, which will be used as the top margin of the parent element. Collapse occurs even if the parent element's top margin is 0. (collapse only occurs in the vertical direction) Solution: 1. Define a 1-pixel top border for the parent element. 2. Define a 1-pixel top padding for the parent element. 3. Add overflow:hidden to the parent element; Note that the first and second methods are not good and will increase the size of the box. The third method hides the overflowing content, which neither increases the size of the box nor affects the content. Summarize The above is what I introduced to you about solving the problem of margin merging. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
<<: Faint: "Use web2.0 to create standard-compliant pages"
>>: Detailed explanation of MySQL transaction isolation level and MVCC
Because some dependencies of opencv could not be ...
The one above shows the system time, and the one ...
This article example shares the specific code of ...
Table of contents Skeleton screen use Vue archite...
What is wxs? wxs (WeiXin Script) is a scripting l...
Table of contents Drop-down multiple-select box U...
This article shares the specific code of Vue impo...
My97DatePicker is a very flexible and easy-to-use...
The ultimate way to solve the parsererror error o...
Recently, I'm learning to use React with Thre...
The <marquee> tag is a tag that appears in ...
Table of contents 1. What is an event? 2. How to ...
A root routing component (the root routing compon...
Transition document address defines a background ...
In MySQL, you can use IF(), IFNULL(), NULLIF(), a...