In css when to use padding and when to use margin
This question already has an answer here:
This image can help you understand better.
To build off of what @G-Cyr said, think of it in terms of pictures on a wall.
Your picture is your element in question; the frame around the picture can be considered the padding, or the immediate space surrounding image, yet unique to that element. Margin could be considered the spacing between two of the pictures on said wall.
From a philosophical standpoint, you may want to defer to margin when changing spacing between two elements.
事实上, 边距用于从外部为空间添加空间,而填充用于在同一事物内部添加空间,但对于您的问题,我不确定您是否正在讨论如何将对齐div组作为示例左边,如果我要这样做,我将使用CSS中提供的关键字alight-left。
链接地址: http://www.djcxy.com/p/29422.html上一篇: 为什么不使用保证金定位而不是使用position:relative top 5px?
下一篇: 在CSS中何时使用填充以及何时使用边距