Input Button hover

Posted: July 6, 2010 in 1

If you have ever tried to put a hover effect on any input element. If  using css you must have faced the problem when you tested on IE6. Generally following is the css code we use to add the hover effect:

input.button{background-color:#ccc;color:#000;}
input.button:hover{background-color:#000;color:#fff;}

This is wrong because input:hover is noting in css. Hover effect use only with a tag in css. The right way off the input hove effect is following:

<input type="submit" value="Submit" onmouseover="this.className='inputClass-hover';" onmouseout="this.className='inputClass'" name="inputName" class="button" id="submit" />

Save the submit bg image

Save the submit hover bg image

This is code of html copy and paste in html

HTML Code

<input type="submit" value="Submit" onmouseover="this.className='inputClass-hover';" onmouseout="this.className='inputClass'" name="inputName" class="button" id="submit" />

CSS

.button, .inputClass {background:url(submit-bg.gif) no-repeat; font:26px Arial, Helvetica, sans-serif; border:none; width:132px; height:38px;}
.inputClass-hover {background:url(submit-hover-bg.gif) no-repeat; font:26px Arial, Helvetica, sans-serif; border:none; width:132px; height:38px;}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s