當placeholder屬性預設的顏色,樣式等不能滿足我們的需要時,需要修改它的樣式。
寫法:input::-webkit-input-placeholder
因為placeholder是 html5 中新增加的屬性,需要注意瀏覽器的相容性。
::-webkit-input-placeholder
/* 使用webkit核心的瀏覽器 */
:-moz-placeholder
/* firefox版本4-18 */
::-moz-placeholder
/* firefox版本19+ */
:-ms-input-placeholder
/* ie瀏覽器 */
舉例:修改placeholder樣式,將input提示框中文字的顏色設為紅色,字型設為20px,讓文字在輸入框中水平居中顯示。**如下
html部分:
type
="text"
id="input"
placeholder
="請輸入使用者名稱"
/>
css部分:
input
#input::-webkit-input-placeholder
#input:-moz-placeholder
#input:-ms-input-placeholder
效果如下:![](https://pic.w3help.cc/e27/59cd054ac1914607a89bfd716f8cc.jpeg)
placeholder屬性指定樣式
input webkit input placeholder 使用webkit核心的瀏覽器 input moz placeholder firefox版本4 18 input moz placeholder firefox版本19 input ms input placeholder 冒號前寫對應的...
placeholder這個屬性 input
input是乙個很常見的標籤,大家使用的也很常見,但是我在具體的工作中發現要想完美的使用這個標籤還是任重而道遠,下面是我碰到的幾個問題。1 我們在使用這個標籤的時候會習慣的加上placeholder這個屬性,起到乙個提示的作用,但是當我們的游標移入的時候提示的文字並沒有消失,這樣就不是我們想要的結果...
修改placeholder的樣式
在input框中有時想將輸入的字和placeholder設為不同的顏色或其它效果,這時就可以用以下 來對placeholder進行樣式設定了。1 webkit input placeholder 使用webkit核心的瀏覽器 2 moz placeholder firefox版本4 18 3 moz...