修改 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>

猜你喜欢

转载自www.cnblogs.com/xupanyuan/p/10121754.html