Jump to content

Fit 2 form inputs into a fixed size container

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
TheSourceOfX

TheSourceOfX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
What code did you use? There are a lot of elements that could be involved.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
TheSourceOfX

TheSourceOfX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
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.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
TheSourceOfX

TheSourceOfX

    Learning Programmer

  • Members
  • PipPipPip
  • 45 posts
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.