I'm trying to create a fluid text input with a submit button to its right. The input and the button should fill 100% of its container.
Here is an approximation of what I'm trying to achieve: http://jsfiddle.net/t7tgJ/
The problem I'm running into to is, in order to have the input fill its container I need to give it a fluid width, like 100%. However if I float the button right, I'll need to bump down that width to something like 90% so that the button can fit. But this only works for one viewport size.
What I want is something like
input { width: 100% - {button.width}; }
button { float: right; }
or, in plain english, my input should extend up to the right-floated button and remain that way at any viewport size.
Although they all expressed good ideas, I was having trouble getting the various suggestions to look consistant across browsers. After iterating on this a bunch I came up with the following solution which looks good for everything > IE7 and doesn't require any additional containers.
http://jsfiddle.net/tjlahr/hUeZS/
Basically the solution for me was:
1) button { float: right; position: relative; top: -28px; }
2) Use browser resets to cancel some of the extra padding and margins that get added to the button element.
3) Set the height of the input and button to further maintain consistant sizes between browsers.