2017-08-09 67 views
1

我有這個代碼在Chrome和Internet Explorer中完美工作。但是每當我結合下面的CSS樣式,它只能在Internet Explorer中工作,而不能在Chrome中工作。佔位符風格不適用於鉻?

有沒有人關於這種奇特的行爲?

.searchBar{ 
 
\t height:50px; 
 
\t width:200px; 
 
\t background-color:#9a005f; 
 
\t color:#fff; 
 
} 
 
.searchBar:focus{ 
 
\t background-color:#9a445f; 
 
} 
 
.searchBar::-webkit-input-placeholder{ 
 
color:#fff; 
 
} 
 
.searchBar::-ms-input-placeholder{ 
 
\t color:#fff; 
 
}
<input type="text" class="searchBar" placeholder="Search for..."/>

編輯: 下面是不是在我的鉻工作,但在IE工作。

.searchBar{ 
 
\t height:50px; 
 
\t width:200px; 
 
\t background-color:#9a005f; 
 
\t color:#fff; 
 
} 
 
.searchBar:focus{ 
 
\t background-color:#9a445f; 
 
} 
 
.searchBar::-webkit-input-placeholder, 
 
.searchBar::-ms-input-placeholder{ 
 
    color:#fff; 
 
}
<input type="text" class="searchBar" placeholder="Search for..."/>

+0

Chrome多年來一直不是webkit瀏覽器,現在大多數供應商前綴都在標誌後面,所以我並不感到驚訝,您所做的不起作用。 – Rob

+0

那麼爲什麼它僅適用於'.searchBar :: - webkit-input-placeholder'? – Pratyush

+0

您的代碼片段適用於我的Chrome。 – Terry

回答

3

我已經做了一些網絡上搜索,我發現了我認爲是the answer你的問題。

請勿混用供應商前綴選擇器(-moz,-webkit,-ms,...)。 Chrome例如不會理解「-moz-」,然後忽略整個 選擇器。