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