As you can see from this example, the input
seems to "overflow" its parent div
. I'd like to add padding to the input
without making it overflow its parent.
I would like to know the best solution/workaround for every browser (including IE, Firefox, Chrome, etc).
You could simply set the container to flexbox. Another option would be using CSS table, some extra HTML code is needed. And max-height doesn't work with table layout, so use height instead. Save this answer.
You can see this answer, but if you don't like it, you can use box-sizing
CSS3 property like this:
input {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
Live jsFiddle example
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