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;}

Leave a comment