I have two form inputs, a text box and a drop down list. They're in a table cell together and I want them to together fill the width of the cell. I tried setting their widths to 50% each, with CSS, but because of something small that I think is built into the forms they end up being ever so slightly too large for the cell, so the second input ends up underneath the first. Is there a way to make them to fill the entire cell on one line? I wouldn't mind fixing the width of one of them if I could figure out how to set the other one to automatically fill the remaining space.
Fit 2 form inputs into a fixed size container
Started by TheSourceOfX, Jul 09 2010 04:40 PM
4 replies to this topic
#1
Posted 09 July 2010 - 04:40 PM
|
|
|
#2
Posted 09 July 2010 - 07:00 PM
What code did you use? There are a lot of elements that could be involved.
#3
Posted 09 July 2010 - 07:44 PM
Oh I'm sorry. I should've posted it before. This is the code...
<tr><td style="width: 300;"> <input style="width: 50%;" type="text" name="income" id="0"> <select style="width: 50%;" name="scale" id="1"> <option value="10" selected="selected">Select pay scale...</option> <option value="20">Per Year</option> <option value="25">Per Month</option> <option value="30">Per Day</option> <option value="40">Per Hour</option> <option value="45">Per Semester</option> <option value="50">Stipend</option> </select> </td></tr>
#4
Posted 10 July 2010 - 06:02 AM
Where's the rest of the CSS? There's about 3 different values involved in spacing, and they have different default values from browser to browser. You may want to specify the width as something like 140, instead of 50%, since you've already specified the cell at 300.
#5
Posted 10 July 2010 - 01:33 PM
I've set padding and margin to 0 elsewhere, I should've said that. Other than those I don't know what could be contributing to the extra space. The padding and margin are also 0 on the forms themselves. I don't want to set the widths to an absolute number though because I may for some reason want to change the size of the cell later and I don't want to have to figure out new sizes for the forms. I copied the relevant parts of the CSS code into my last post, but in reality it's all spread around; I'm using symfony. And I don't want to make separate CSS classes for those two forms if I can avoid it. I'm really looking for something more automatic, so that the browser will figure out how big they have to be to fill the cell completely.


Sign In
Create Account


Back to top









