What's the relationship between margin, padding and width in different browsers?

后端 未结 5 2322
死守一世寂寞
死守一世寂寞 2021-02-20 00:07

CSS width value = display width of inside?

or

CSS width value = display width of inside + CSS margin-left + CSS margin-right?

5条回答
  •  情书的邮戳
    2021-02-20 00:30

    You have to make yourself familiar with the CSS Box Model. It explains where padding, margin and border as well as width work.

    However do note that different browsers implement this differently: most notably, Internet Explorer has a box model bug (this is infamously present in IE6 -- I am not aware if this has been fixed in IE7 or IE8) that caused the infamous "quirks mode" CSS hack.

    Briefly stated, Internet Explorer set their box model to include padding in computing the width, as opposed the official standard wherein width should only constitute the content.

提交回复
热议问题