Sometimes, we want to change a DIV padding without affecting the width/height with CSS.
In this article, we’ll look at how to change a DIV padding without affecting the width/height with CSS.
How to change a DIV padding without affecting the width/height with CSS?
To change a DIV padding without affecting the width/height with CSS, we set the box-sizing properties.
For instance, we write
* {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
to set box-sizing to border-box to stop padding from changing the width and height of the any element.
Conclusion
To change a DIV padding without affecting the width/height with CSS, we set the box-sizing properties.