html中input提示文字樣式修改

在很多網站上我們都看到input輸入框顯示提示文字,讓我們一起來看看如果在input輸入框中顯示提示文字。我們只需要在<input>標籤里添加:placeholder=”提示文字即可”,那麼如果要修改提示文字的樣式呢?可以這樣設置css樣式:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>input輸入框提示文字</title>
<style>
/*修改提示文字的顏色*/
input::-webkit-input-placeholder { /* WebKit browsers */ 
color: red; 
}
input:-moz-placeholder { /* Mozilla Firefox 4 to 18 */ 
color: red; 
}
input::-moz-placeholder { /* Mozilla Firefox 19+ */ 
color: red; 
}
input:-ms-input-placeholder { /* Internet Explorer 10+ */ 
color: red; 
}
</style>
</head>
<body>
<input type="text" placeholder="請輸入用戶名" />
</body>
</html>

修改後提示文字樣式如下: