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

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

    To achieve a consistent result cross browser, you would usually add another div inside the div and give that no explicit width, and a margin. The margin will simulate padding for the outer div.

提交回复
热议问题