Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertically center input field

Tags:

html

css

center

I have a text input field on a page, however, I'm finding it difficult trying to vertically center the field in webkit (Chrome + Safari). It is fine in FireFox.

Here's the code:

<form action="/" method="get">
    <input type="text" name="s" id="search" class="search" size ="34" value="Search..." onblur="if(this.value == ''){ this.value = 'Search...'; this.style.color = '#BBB';}" onfocus="if(this.value == 'Search...'){ this.value = ''; this.style.color = '#000';}" />
    <input class="schbtn"ntype="submit" value="" />
</form>

And the CSS:

.schbtn {background:url(/wp-content/themes/shamil/images/search_icon.png) no-repeat scroll 50% 50% #7BA60D;height:26px; width:26px;}
#navtabs li.rnavtab input{border:0;padding-left:5px;color:#BBB;}

These are the only two which affect it.

For those wanting to see this in action, visit, http://shamil.la, and observe the search field in both Firefox and Safari/Chrome. It's driving my head up the wall.

Thanks

like image 569
bear Avatar asked Apr 30 '26 10:04

bear


1 Answers

Put a vertical-align:middle; on both of the input elements, and that will center it

like image 57
Brett Avatar answered May 04 '26 06:05

Brett



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!