当前位置 : 主页 > 网页制作 > css >

margin padding border

来源:互联网 收集:自由互联 发布时间:2021-06-13
Difference between margin and padding? Remember these 3 points: The Margin is the extra space around the control. The Padding is extra space inside the control. The Padding of an outer control is the Margin of an inner control . Demo Image:

Difference between margin and padding?

Remember these 3 points:

  • The Margin is the extra space around the control.
  • The Padding is extra space inside the control.
  • The Padding of an outer control is the Margin of an inner control.

Demo Image:(where red box is desire control

 

When to use margin vs padding in CSS [closed]

From https://www.w3schools.com/css/css_boxmodel.asp

Explanation of the different parts:

  • Content - The content of the box, where text and images appear

  • Padding - Clears an area around the content. The padding is transparent

  • Border - A border that goes around the padding and content

  • Margin - Clears an area outside the border. The margin is transparent

Live example (play around by changing the values): https://www.w3schools.com/css/tryit.asp?filename=trycss_boxmodel

网友评论