简体   繁体   中英

Button image moves up slightly when being clicked (in Internet Explorer)

Does anybody know why an image may move/jerk slightly while being clicked (only happens in IE)? This is our button:

<button class="join" name="register" value="" onClick="window.location = 'location'" tabindex="4"></button>

This is the class:

button.join {
        background: url(../images/join.png);
        border: 0;
        height:  56px;
        width: 178px;
        cursor: pointer;
        }

Button tags are always a hassle to get styled correctly cross-browser. As long as you're using javascript for the onClick there's no real reason to use the button tag. Try using an anchor tag, targeting all states and setting the position of the image.

<a class="join" href="#" id="register" onClick="window.location = 'location'" tabindex="4">Button</a>

a.join:link,
a.join:visited
a.join:hover,
a.join:active
{
        background: url(../images/join.png) 0 0 no-repeat;
        border: 0;
        text-indent: -999em; /* Optional - To remove the HTML text from the button */
        height:  56px;
        width: 178px;
        cursor: pointer;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM