.ant-menu-vertical .ant-menu-submenu, .ant-menu-vertical-left .ant-menu-submenu, .ant-menu-vertical-right .ant-menu-submenu, .ant-menu-inline .ant-menu-submenu {padding-bottom: 0.02px;}
System A is antd v3.26.6 while system B is v3.19.8, I am migrating A to B and find the menu li margin collapsed after the migration, so I looked deeper, and found that the newer version of antd menu has a padding-bottom: 0.02px; while the older is 0.01px, and put this in chrome for test, you can see 0.02px is the minimal pixel for browser to prevent the collapse while causing no difference to our eyes. Interesting one. So I checked antd’s code base, and here I see this comment:
// disable margin collapsed.@{menu-prefix-cls}-submenu {padding-bottom: 0.02px;}
So, this is a design change. But why 0.01px in the beginning, the related commit. So it’s initially supposed to avoid the collapse, but incurred a bug, and later fixed.
more about vertical margin collapse
ref: https://css-tricks.com/what-you-should-know-about-collapsing-margins/
- collapse happens when two elements with margins sit with each other
- if both margins are positive numbers, then the bigger one effectives the margin between, while the smaller one is ‘swallowed’, ie
bigger margin = total vertical margin - if there is a negative margin, the final margin should be
total vertical margin = positive margin + negative margin, like50px + (-25px) - if both are negative, then
total vertical margin = smaller negative margin, like-25pxand-50px, then the total margin should be-50pxwhen parents ground their children
As long as something solid sits between these margins, the should not collapse.
So, if children are nested one by one, one way to avoid collapse is to give a padding to each layer: ```htmlCollapsing Child Margins
```css/* PRESENTATIONAL STYLES */html {font-size: 16px;}body {background-color: #333;color: #fff;font-family: Helvetica;padding: 25px;text-align: center;}h1 {font-size: 2em;font-weight: 800;}/* DEMO STYLES *//* Parent */div {margin: 15px 0;}/* Add padding to the parent */.padding {padding: 20px 0;}/* Here come the children */.red {background-color: #ff6b6b;}.orange {background-color: #ff9e2c;}.yellow {background-color: #eeee78;}.green {background-color: #4ecd9d;}.blue {background-color: #4e97cd;}.purple {background-color: #6c4ecd;}

