I have the following code
<table style="min-width:70%; font-size:12px;">
<tr style="background:#BDBDBD">
<th style="border:1px solid #000;text-align:center" width="25%" colspan="2">$us Pto.</th>
<th style="border:1px solid #000;text-align:center" width="25%" colspan="2">Costo en $us</th>
<th style="border:1px solid #000;text-align:center" width="25%" colspan="2">costo en Bs.</th>
<th style="border:1px solid #000;text-align:center" width="25%" colspan="2">Costo Por Tonelada</th>
</tr>
<tr>
<td style="border:1px solid #000;text-align:center" >Zn</td>
<td style="border:1px solid #000;text-align:center" ><input size="7" style="text-align:center" type="text"></td>
<td style="border:1px solid #000;text-align:center" >Zn</td>
<td style="border:1px solid #000;text-align:center" ><input size="7" style="text-align:center" type="text" readonly></td>
<td style="border:1px solid #000;text-align:center" >Zn</td>
<td style="border:1px solid #000;text-align:center" ><input size="7" style="text-align:center" type="text" readonly></td>
<td style="border:1px solid #000;text-align:center" ><input size="7" style="text-align:center" type="text" readonly></td>
<td style="border:1px solid #000;text-align:center" ><input size="7" style="text-align:center" type="text" readonly></td>
</tr>
</table>
As you can see , the ones input
inside a td
have a size that leaves spaces to the left and right of the , I achieved this with the input td
attribute .size
But I want the input
s to occupy 100% of the td
, so my question is:
How to make an input occupy 100% of a td?
As they mentioned in the comments you can use
width: 100%
but this will not work well if you do not change thebox-sizing
aborder-box
because the default valuecontent-box
makes the calculation not correct as you can check herePutting it to the inputs already calculates it correctly
This reset is widely used to apply this correction to all elements but it can affect a layout that is already established. The ideal is to start building it with the reset applied from the beginning
This is one of the changes that Bootstrap applies by default when you include it on your site.