Forum Moderators: not2easy

Message Too Old, No Replies

Select and Text Input Heights in Firefox

         

Lupi

3:44 am on Dec 22, 2010 (gmt 0)

10+ Year Member



Good evening,

I am trying to align two forms in one line, the first one a select field (site selection) and the second one a text field (search).

I do not intend to apply any CSS styling to the select or the text field, but I use the same image button as the submit button (GO).

-------------- ------ ------------ ------
| SELECT v | | GO | | SEARCH | | GO |
-------------- ------ ------------ ------

Basically, everything is supposed to be "in line" (same height).

HTML:


<div id="header_selections">
<form method="post" action="">
<select class="header_formfield">
<option>Option 1</option>
<option>Option 2</option>
</select>
<input type="image" src="" />
</form>
</div>

<div id="header_selections">
<form method="post" action="">
<input type="text" class="header_formfield" />
<input type="image" src="" />
</form>
</div>


CSS:


#header_selections {
float: left;
height: 55px;
padding-left: 70px;
padding-right: 0px;
display: inline-block;
}

.header_formfield {
font-family: Arial,Helvetica,sans-serif;
font-size: 13px;
height: 20px;
width: 180px;
}


The problem is that the text field is 2px higher than the select field in FF (it's also higher in IE, but let's focus on FF first). I checked with FireBug (-> Computed), and the select field shows "box model height: 20px", border-top/bottom/left/right: 0". It still shows the standard "border" you would expect when using unstyled form elements (I want to keep that standard border). The text field also shows "box model height: 20px", but also shows border-top/bottom/left/right: 1px". Even though it shows exactly the same standard border as the select field. So with the top and bottom 1px borders, the actual height is 22px, and thus the layout out of line.

Any ideas? Is this a FF problem, or related to something in my code?

I appreciate your help.

Cheers, Chris

TheKiller

4:30 am on Dec 22, 2010 (gmt 0)

10+ Year Member



Hey

Apologizes but i have no idea what you are trying to do ........
What dos it have to submit ?

there arent any names defined to what to submit :|

Maybe this is what you want?


<html>

<head>
<title>Test Form</title>

<style type="text/css">
#header_selections {
float: left;
height: 55px;
padding-left: 70px;
padding-right: 0px;
display: inline-block;
}

.header_formfield {
font-family: Arial,Helvetica,sans-serif;
font-size: 13px;
height: 20px;
width: 180px;
}

</style>
</head>

<body>

<form method="post" action="">

<select class="header_formfield">
<option>Option 1</option>
<option>Option 2</option>
</select>

<input type="image" src="" />



<input type="text" class="header_formfield" />
<input type="image" src="" />

</form>
</body>
</html>

Lupi

4:47 am on Dec 22, 2010 (gmt 0)

10+ Year Member



My apologies for not making myself clearer. I simplified the code quite a bit and removed name, id etc. attributes.

I am floating two forms, form 1 has one select field (drop down) and uses an image as the submit button. Form 2 has one text field (to enter search terms) and also uses an image as the submit button. Assigning the same height of 20 px to both the SELECT and the INPUT fields, and floating them (float: left;), I would expect both elements to be exactly 20px in height and thus perfectly aligned vertically ("in line").

However, that is not the case. The SELECT element is in fact 20px high, whereas the INPUT element is 22px high. Since I assigned no borders, no padding, no margins, I have no explanation why this happens.

I realized that with FireBug's "computed values", it shows 20px height for both elements, but for the INPUT, it also shows a 1px border-top-width and border-bottom-width (thus 20px + 1px + 1px = 22px displayed height of the box model in FF). It shows border-top-width and border-bottom-width: 0 (!) for the SELECT. Both fields however look exactly the same and have the "default look" (compare the search text field here on WebmasterWorld, this is what I call "default/standard look/border". Hope I could help clarifying things.

Thanks, Chris

TheKiller

12:55 am on Dec 23, 2010 (gmt 0)

10+ Year Member



Did you look at my example?

Why do you need two form tags ?
dos each form has a separate Action ?

you should have let it like that .. that way me and others could have got and idea of how you submit the forms etc

i think the example i made looks like what you want