修改palceholder內文字的css樣式css
1 ::-webkit-input-placeholder{ 2 color: red; 3 font-size: 20px; 4 line-height: 50px; 5 }
修改class名爲test1的元素palceholder內文字css樣式html
.test1::-webkit-input-placeholder{ color: red; font-size: 20px; line-height: 50px; }
例子:web
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style> input{ height: 50px; font-size: 14px; line-height: 50px; } .test1::-webkit-input-placeholder{ color: red; font-size: 20px; line-height: 50px; } </style> </head> <body> <input class="test1" type="text" placeholder="測試" /> <input type="text" placeholder="測試" /> </body> </html>
效果圖:瀏覽器
至於兼容,加上相應瀏覽器的前綴測試