How to change a DIV padding without affecting the width/height ?

后端 未结 5 700
死守一世寂寞
死守一世寂寞 2020-12-22 18:52

I have a div that I want to specify a FIXED width and height for, and also a padding which can be changed without decreasing the original DIV width/height or increasing it,

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-22 19:52

    Sounds like you're looking to simulate the IE6 box model. You could use the CSS 3 property box-sizing: border-box to achieve this. This is supported by IE8, but for Firefox you would need to use -moz-box-sizing and for Safari/Chrome, use -webkit-box-sizing.

    IE6 already computes the height wrong, so you're good in that browser, but I'm not sure about IE7, I think it will compute the height the same in quirks mode.

提交回复
热议问题