Forum Moderators: not2easy
<table style="width: 100%">
<tr>
<td>Hello World</td>
<td><input id="txtOne" style="width: 100%;"></input></td>
</tr>
<table>
I've tried lots of various combinations of nested divs and spans using various css display values but I can't get the same effect.
I need this because I don't know the width of my containing element but I want to maximize the size of my text box.
I know this is probably one of those "duh", I should have thought of that things but I can't figure it out.
I'd be interested in knowing this as well. Using block-based structure (
<div></div>), I have had to do the same kind of thing, but I have specified the sizes. <table></table> does give you this, and you may not be able to reproduce it exactly with block-based structure.
[edited by: Xapti at 4:27 am (utc) on Sep. 15, 2007]
<div style="float:left;width:8em">Label:</div><form style="display:block;margin-left:8em"><div><input style="width:100%"></div></form>
(I added a
<div></div> inside the <form></form> so it can validate for me). The problem with this is that the label has to be an arbitrary size. Your example has a fixed label size.
It is an improvement over what I've done in the past, as it does allow me to specify an arbitrary size for the
<input>. It's making both of them arbitrary that's an issue.
In some cases, a
<table></table> is your only choice. There's nothing wrong with using one when that is the only viable remedy. In this case, it doesn't look like it needs to be a big deal to add a small <table></table> here and there as needed.