Margin on child element moves parent element

前端 未结 14 2186
广开言路
广开言路 2020-11-21 23:38

I have a div (parent) that contains another div (child). Parent is the first element in body with no

14条回答
  •  一整个雨季
    2020-11-22 00:24

    An alternative solution I found before I knew the correct answer was to add a transparent border to the parent element.

    Your box will use extra pixels though...

    .parent {
        border:1px solid transparent;
    }
    

提交回复
热议问题