I have a text input inside a <td>
that has a padding of 5px
; When setting its width to 100%
it comes out of the boundaries of the <td>
for 10px
. Is there a way to make it fill the entire <td>
(i.e. in practice its width should become 100% - 10px
) without using JavaScript?
Thanks in advance
I had asked this question back in 2010 and as far as I can remember there wasn't a reasonable solution available back then.
However thanks to CSS3, two solutions are now available:
box-sizing: border-box;
width: 100%;
width: calc(100% - 10px);
Some browsers might need vendor prefixing (e.g. width: -moz-calc(100% - 10px);
).
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