Pretty interesting. I think there are a couple of interesting regressions happening because you do margin-top: -1px
and you also float a pseudo element inside the <li>
which causes some interesting things with the document flow.
Removing one or the other makes it seem to work as expected.
You could also put a clear: both
on the :before
pseudo element which will specify to the browser that the floating elements shouldn't try to float on the same line. That also seems to help a little.
I actually think the heart of the issue lies with the fact that <li>
by default comes with its own "margin-top" with the default style of -webkit-margin-before: 1em
. It seems setting li
to have a style of -webkit-margin-before: 0em
also solves the issue. For more information of -webkit-margin-before
, see this answer
In all honesty, I'm still looking into it so I'll try to update my answer if I can. One thing I am looking into is it could be the result of margin-collapsing but I don't have enough evidence to support it.
Specifically this excerpt might suggest a clue:
When negative margins are involved, the size of the collapsed margin is the sum of the largest positive margin and the smallest (most negative) negative margin.
If both are negative, the greater negative value is used. This definition applies to adjacent elements and nested elements.
Margins of floating and absolutely positioned elements never collapse.