2015-03-31 68 views
0
#buttonShareMap:disabled { 
    background:black; 
} 

如果禁用了按鈕,它會將我的按鈕的顏色更改爲黑色。當鼠標移過時更改按鈕的css

然而,如果禁用,並且用戶持有光標放在它改變到藍色按鈕,這是彩色如果按鈕被啓用通常它是 類=「編輯藍色BTN」 .....

我想保持按鈕黑色在任何時候,當它被禁止......因此,它是這樣的:

.buttonShareMap:disabled:hover 
{ 
    background:black; 
} 

不能得到它的工作...任何想法? ta

此外,光標變爲鼠標時,只需將鼠標放在禁用的按鈕上即可。我希望它保持爲一個光標,並且只有在按鈕被啓用的情況下才轉換爲鼠標。

+0

一旦元素被禁用,我相信它不再升高* *任何事件,因此'hover'不會閃光就可以了。 – 2015-03-31 14:38:18

+0

Havey您嘗試過使用「:active」嗎? – 2015-03-31 14:38:57

+0

使用!重要覆蓋 – 2015-03-31 14:40:30

回答

2

你可以使用!important,這應該工作。背景可能是由級聯寫的。最好是找到並更正它,而不是!important,但如果你需要一個快速和骯髒的解決方案,它將工作。另外,您可以將光標設置爲禁用時的默認光標。結合在一起的CSS將是:

#buttonShareMap:disabled { 
    background:black !important; 
    cursor:default; 
} 
+0

感謝您的回答G – John 2015-03-31 16:15:44

0
A disabled button wont be able to catch the JS events like hover, mouseover etc. If you want to change your disabled button color, you can directly do it using CSS. You can do something like: 

<style> 
input.button:disabled{ background: #000; color: #FFF; cursor: default;} 
</style> 

<input type="button" class="button" value="Button" disabled> 

If the background color is not picked you can add an !important with the CSS rule.