Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button not aligned with input (due to padding of input)

The button below is not aligning with the input. The input has to be on the same height as the button, though the padding of the input seems to have a influence on the alignment! The difference between padding-top and padding-bottom creates this shift of the button.

I made a fiddle: http://jsfiddle.net/3RMhm/10/ to show what I mean.

CSS:

.button {
    font-size: 15px;
    padding: 9px 23px;
    border:0;
}
.form  {
    width: 290px;
    background-color: #F9F9F9;
    font-size: 18px;
    color: #333;
    height: 25px;
    border:1px solid darkgray;
    padding-top: 15px;         <--- This padding
    padding-bottom: 0px;       <--- And this padding
}

HTML:

<input name="name" class="form" /> 
    <input class="button" type="submit">
like image 226
Tom Groot Avatar asked Sep 05 '13 18:09

Tom Groot


2 Answers

Just add vertical-align: middle to both elements (button and input).

http://jsfiddle.net/3RMhm/3/

like image 161
Explosion Pills Avatar answered Sep 22 '22 22:09

Explosion Pills


Use:

vertical-align:middle;
margin-top: -5px;

http://jsfiddle.net/Hive7/3RMhm/2/

like image 33
Hive7 Avatar answered Sep 20 '22 22:09

Hive7