2014-09-29 86 views
2

嘗試將樣式應用於佔位符我遇到問題,即在IE(所有版本)佔位符文本顏色不適用。它只需要輸入文字的顏色Internet Explorer佔位符樣式問題

:-ms-input-placeholder { 
    color: white; 
} 

input { 
    color:black; 
} 

應用此代碼後,佔位符的顏色將變爲黑色。

可能是什麼問題?

回答

0

解決方案:

在我的CSS我的表單輸入指定(div_name格式>輸入{})對於瀏覽器而言,這是比指定爲選擇器更有價值的文本的顏色:-ms-input-placeholder {}佔位符顏色。 (這很奇怪,他們是爲了不同的目的,但確定)

1

你需要指定此規則,以特定的輸入:

input:-ms-input-placeholder { 
    color: white; 
} 

input { 
    color:black; 
} 

Internet Explorer Dev Center

選擇:-MS-輸入佔位符{...}

請注意,這僅適用於IE> 10瀏覽器。

+0

我有IE 10,這對我不起作用。 – eatmypants 2014-09-29 15:00:40

+0

您確定兼容模式未啓用且您的瀏覽器不能在Quirks模式下工作嗎?你的網頁上有文字嗎? – antyrat 2014-09-29 15:02:56

+0

是的 - 我確定。 Doctype也在我的html中 – eatmypants 2014-09-29 15:10:03

0

如果您正在尋找支持所有瀏覽器看看這個答案:

How to support placeholder attribute in IE8 and 9

+0

OP尋找樣式佔位符,而不是在舊版瀏覽器中啓用它。也鏈接只有答案應該是意見而不是http://meta.stackexchange.com/questions/8231/are-answers-that-just-contain-links-elsewhere-really-good-answers – antyrat 2014-09-29 15:08:11

+0

已經使用它,但我添加後它 - IE <10佔位符的顏色與IE10中的顏色相同。 – eatmypants 2014-09-29 15:08:25

+0

或標記爲重複項 – antyrat 2014-09-29 15:08:34