修改 input中的placeholder的字体样式和颜色

时间:2023-03-08 20:18:11
修改 input中的placeholder的字体样式和颜色

placeholder属性是css3中新增加的属性,

由于是新加入的属性因此对各大浏览器都不兼容:

因此在使用的时候要加兼容性

  火狐:-moz-placeholder { /* Mozilla Firefox 4 to 18 */

  color:#999;

  }

 火狐 ::-moz-placeholder { /* Mozilla Firefox 19+ */

  color:#999;

  }

 ie浏览器 :-ms-input-placeholder { /* Internet Explorer 10+ */

  color:#999;

  }

谷歌 ::-webkit-input-placeholder { /* WebKit browsers */

  color:#999;

  }

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.test::-webkit-input-placeholder{
color: red;
} </style>
</head>
<body>
<input class="test" type="text" placeholder="测试" />
<br />
<input type="text" placeholder="测试" />
</body>
</html>

修改 input中的placeholder的字体样式和颜色