English 中文(简体)
Text in disabled and css styled button shows movement in IE
原标题:

I have disabled and css styled buttons. In Firefox, disabled buttons do not move at all when pressed (which is what is expected), in IE, the text in the buttons still moves a few pixels.

Why does this happen and more importantly, how do I make disabled styled buttons actually disabled in IE?

最佳回答

It s how this particular browser is implemented. Out of your control.

With web development, it is a good idea not to think pixel-precise, otherwise browser inconsistencies will eventually drive you insane.

问题回答

You cannot change the browser styles for disabled buttons in IE, but you could wrap your button like this:

<div class="button-wrap">
    <a class="button" disabled="disabled"><span>My button</span></a>
    <span class="visible-text">My button</span>
</div>

Then position and style visible-text as you want preventing that weird movement you say. Something like this:

.visible-text {
    position: absolute;
    cursor: pointer;
    color: green; /* or whatever... */
}

Using visibility: hidden on the default button text keeps the width of the button so you can position there the same text without any problem.

a.button span {
    visibility: hidden;
}

Please try it here:

http://jsfiddle.net/fnwjT/47/

well, a little late but you could set the :active pseudo class for disabled buttons to 0px.

button[disabled]:active{
     top: 0;
}




相关问题
Image rendered with wrong colors in IE8

I have a gradient image as a PNG (no transparency) in a web-page. By taking a screenshot of Chrome showing the page and cropping the image from the page, I see the exact same colors are drawn as the ...

Determine Mobile Internet Explorer version

I need to determine the version of Mobile Internet Explorer on a Windows Mobile 6.1 device. So that I can report the same user-agent string as is being used by Mobile Internet Explorer. The user-...

CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

Internet Explorer only part loading JavaScript/CSS

I m having trouble with my local development environment where IE (6 through to 8) is only part loading JavaScript/CSS files. It throws random errors at random places in jquery.min.js every time I ...

IE doesn t run Javascript when you click back button

I ve built a shop with tons of JS running. One of the pieces of the cart, is a zip code field which is required to calculate shipping cost. This works fine going through the cart. Now clicking ...

热门标签