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

后端 未结 5 2325
死守一世寂寞
死守一世寂寞 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:18

    As mentioned by others, the rule of thumb is the CSS box model. This works generally as advertised by browsers such as Opera, Firefox & Safari. Internet Explorer is your exception, where the "width" includes the margins, padding and borders.

    There are some great tools out there that visually depict how the browser has rendered the content. For Firefox check out Firebug and for Internet Explorer check out the Developer Toolbar.

提交回复
热议问题