I use padding in many of my projects, and it would be handy if I could substract the padding from the width, it is possible ?
if:
width:100%;
and
padding: 20px;
=
100% - 40px ?
You can use box-sizing: border-box
to make the padding
be counted as part of the width
.
div {
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
Here's a quick demonstration: http://jsfiddle.net/thirtydot/DNs2u/
More info:
width: calc(100% - 40px);
more calc() uses: CSS Tricks: A Couple of Use Cases for Calc()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With