Absolute positioning ignoring padding

后端 未结 3 1356
情书的邮戳
情书的邮戳 2021-01-11 13:19

I am trying to position a div with buttons at the bottom of a parent div that has a padding.

The expected result is having the button resting on top of the

3条回答
  •  感动是毒
    2021-01-11 13:52

    You have two issues here:

    First Issue

    Your buttons are absolute but the first parent element that has a relative positioning is the mcontainer element. Thus, the buttons will only be absolute to this element.

    Remove position:relative from the mcontainer element, and set the body element to have relative positioning.

    Second Issue

    As Turnip had pointed out, padding doesn't get taken into account for absolute positioning. Thus, offset this by setting a negative bottom and left styling to the button container.

    See the fiddle: https://jsfiddle.net/6smpvqq8/1/

提交回复
热议问题