Margin-top not working for

and tag?

前端 未结 6 1117
小蘑菇
小蘑菇 2021-02-01 02:57

I have been trying to implement margin-top for a link button but it doesn\'t work at all. I have also tried inline styles for both \'p\' and \'a\' tag.

There are 3 li el

6条回答
  •  一整个雨季
    2021-02-01 03:11

    This issue is known as Margin Collapse and happens sometimes between top and bottom margins on block elements.

    The margins of adjacent siblings are collapsed

    That's why the margin doesn't work on the p tag. To make it work here an option is to use padding-top on the p tag.

    And on the a tag the margin doesn't work because it's an inline element. You may need to change its display property to inline-block or block.

提交回复
热议问题