.. been trying to fit the textbox (auto adjust the textbox width) within HTML table's cell but no luck.. can anyone please help? thanks
What I have:
<td>
<asp:TextBox ID="txtPrice" runat="server" style="width:100%"/>
</td>
set your "textbox" (whatever that is... do you mean textarea or an input type="text" ?) to 100% width and hight and it's margin to 0 and set the padding of your table-cell to 0.
Fit text automaticallyOn the Text Box Tools Format tab, in the Text group, click Text Fit, and do one of the following: To reduce the point size of text until there is no text in overflow, click Shrink Text On Overflow. To shrink or expand text to fit in the text box when you resize the box, click Best Fit.
On the Layout tab, in the Cell Size group, click in the Table Column Width box, and then specify the options you want. To make the columns in a table automatically fit the contents, click on your table. On the Layout tab, in the Cell Size group, click AutoFit, and then click AutoFit Contents.
This works for me:
<asp:TextBox ID="txtPrice" runat="server" width=100%"/>
However, there is overflow to the left I'll see what I can do
"Textboxes" like <textarea>
are inline elements. You need to make this:
HTML:
<textarea class="myTextarea">
Content
</textarea>
CSS:
.myTextarea
{
display: block;
width: 100%;
height: 100%;
}
Example for you here.
And an updated example for you here. (With margins added and a table for you to see it working in)
Also, do you have some code we can see? textbox
isn't valid HTML so we have no idea what you're trying to use :)
Try this:
<td>
<textarea style="width:100%;height:100%;margin:0;padding:0;" rows=1 cols=1>
text!
</textarea>
</td>
in my tests, it worked.
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