Say, I have the following unordered list. The button has width: auto. How do I style the elements, so #textField would stretch as much as possible, so the width of #textField and the button would add up to 100%? I.e. #textField‘s width == (100% of width) – (button’s computed width).
<ul>
<li>
<input id="textField" type="text" /><input type="button" />
</li>
</ul>
So, for example, let’s say 100% width of li is 100 pixels: if the button’s computed width is 30px, #textField‘s width would be 70px; if button’s computed width is 25px, #textField‘s width would become 75px.
You can quickly achieve this effect using a mixture of
floatandoverflow: hidden:CSS:
Preview (with box-sizing): http://jsfiddle.net/Wexcode/E8uHf/546/
Here is how it looks without box-sizing: http://jsfiddle.net/Wexcode/E8uHf/