Margin-Top push outer div down

前端 未结 8 1222
借酒劲吻你
借酒劲吻你 2020-11-22 09:30

I have a header div as the first element in my wrapper div, but when I add a top margin to a h1 inside the header div it pushes the entire header div down. I realize this ha

8条回答
  •  醉酒成梦
    2020-11-22 09:44

    Adding a tiny bit of padding to the parent element top can fix this issue.

    .parent{
      padding-top: 0.01em;
    }

    This is useful if you need an element inside the parent to be visible outside the parent element, like if you are creating an overlapping effect.

提交回复
热议问题