怎么修改placeholder字体的css样式


修改palceholder内文字的css样式

1 ::-webkit-input-placeholder{
2     color: red;
3     font-size: 20px;
4     line-height: 50px;
5 }

修改class名为test1的元素palceholder内文字css样式

.test1::-webkit-input-placeholder{
    color: red;
    font-size: 20px;
    line-height: 50px;
}

例子:

<!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>

效果图:

至于兼容,加上相应浏览器的前缀

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM