Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I align input field and submit button (also differences between: IE, FFox, Chrome)?

Tags:

css

I am having problems styling form fields with CSS. As you can see below I am trying to get an input field and then to its right the submit button. However for some reason I can't get them to align correctly on any browser, nor can I get them to at least look the same in them and finally everything goes bad when I zoom as well!

I have tried the "line-height:normal !important;" solution, but that doesn't seem to work either...

What am I doing wrong?

IE7 (xp)

IE7
FFox (linux)

FFox
Chrome (linux)

Chrome
CSS (nothing for subscribe_form):

#form_box {     position: relative;     height: 35px;     top: 7px;     left: 20px;  }  #subscribe_email {     border: solid 1px #CCC;     height: 24px;     width: 250px;     font-size: 15px;     color: #999;     padding-left: 5px; }  #subscribe_submit {     position: relative;     border: solid 1px #CCC;     height: 25px;     width: 115px;     color: white; } 

HTML:

        <div id="box2" class="tbox">             <div id="form_box">             <form id="subscribe_form" action="subscribe" method="post">                 Sign Up:                 <input class="tbox" id="subscribe_email" type="text" name="email" value="email address" />                 <input class="tbox" id="subscribe_submit" type="submit" value="Subscribe" />             </form>             </div>         </div> 
like image 373
o1iver Avatar asked Feb 22 '11 03:02

o1iver


People also ask

How do I align a form vertically in CSS?

You can do it using by nesting your entire form in a <div> with an id and then styling that particular div with height: 100%; width: 100%; display: flex; .


2 Answers

Here is what works for me in FF, IE8 and Chrome on XP

#subscribe_email {     border: solid 1px #CCC;     height: 21px;     width: 250px;     font-size: 15px;     color: #999;     padding-left: 5px;     vertical-align: bottom }  #subscribe_submit {     border: solid 1px #CCC;     height: 25px;     width: 115px;     color: white; } 

I removed CSS on the #form_box div, set vertical-align:bottom and tweaked the height on text box.

like image 122
Chris Broski Avatar answered Sep 28 '22 09:09

Chris Broski


you should try floating them both left, that way they will position themselves.

like image 43
martincarlin87 Avatar answered Sep 28 '22 10:09

martincarlin87