Reputation: 6131
I have a search button following an input field, specified like this:
<div class="sidebarsection">
<input id="queryfield" placeholder="Search previews...">
<button class="search-button" onclick="runSearch()"><img src="images/search.png" /></button>
</div>
The associated CSS is
#queryfield {
width: 130px;
box-sizing:border-box;
-moz-box-sizing:border-box; /* Firefox */
}
.search-button {
width: 26px;
padding: 0px;
vertical-align: top;
}
.search-button img {
height: 16px;
width: 16px;
}
In FireFox, this looks correct, like this:
In IE, this looks wrong: the image is offset near the top:
In Safari on the iPad, this is also wrong:
In Chrome, it's also not right:
Is there a way to make all browsers display the image as FireFox does in the above examples?
Upvotes: 3
Views: 546
Reputation: 5957
Well the vertical-align
rule is quite buggy and should probably be avoided if you want full control of the look in multiple browsers: http://reference.sitepoint.com/css/vertical-align
Why not use positioning to get what you want or resize your inner image to be the exact height and width of what you want your button to be.
Upvotes: 2
Reputation: 32182
Used to this way remove img tag
and apply in background image
in your button
as like this
<button class="search-button" onclick="runSearch()"></button>
Css
.search-button{
background:url('../images/search.png') no-repeat center cetner;
width: 26px;
height:26px;
}
Upvotes: 2