美文网首页工作生活
css input的placeholder属性怎么改变颜色等

css input的placeholder属性怎么改变颜色等

作者: 楠楠_c811 | 来源:发表于2019-07-04 19:03 被阅读0次

业务需求需要改变默认颜色
用css设置placeholder属性代码
input::-webkit-input-placeholder

直接在样式中写下面代码,也可以在里面改变字体大小,对齐位置等。
代码示例:

input::-webkit-input-placeholder {
        color: #EEE;
        font-size:14px;
        text-align: right;
    }

顺便提一提兼容性,以备不时之需。
要是浏览器不显示的话就把一些代码放在一起可兼容注释中的浏览器.

::-webkit-input-placeholder { /* WebKit, Blink, Edge */    color:    #909; }

:-moz-placeholder { /* Mozilla Firefox 4 to 18 */   color:    #909; }

::-moz-placeholder { /* Mozilla Firefox 19+ */   color:    #909; }

:-ms-input-placeholder { /* Internet Explorer 10-11 */   color:    #909; }

相关文章

网友评论

    本文标题:css input的placeholder属性怎么改变颜色等

    本文链接:https://www.haomeiwen.com/subject/ntsrhctx.html