Ignore parent padding

后端 未结 12 868
梦如初夏
梦如初夏 2021-01-30 19:23

I\'m trying to get my horizontal rule to ignore the parent padding.

Here\'s a simple example of what I have:

#par         


        
12条回答
  •  执笔经年
    2021-01-30 19:56

    If you have a parent container with vertical padding and you want something (e.g. an image) inside that container to ignore its vertical padding you can set a negative, but equal, margin for both 'top' and 'bottom':

    margin-top: -100px;
    margin-bottom: -100px;
    

    The actual value doesn't appear to matter much. Haven't tried this for horizontal paddings.

提交回复
热议问题