css: webkit-input-placeholder 背景色

标签 css background webkit placeholder

尝试设置占位符背景颜色。在我尝试增​​加输入字段高度之前,它工作正常。在 mozilla 和 ie 中,占位符背景填充输入中的所有空间。但在 webkit 背景中,仅为占位符文本高度设置。

这是一个例子:http://jsfiddle.net/3zp36wL7/2/

::-webkit-input-placeholder { 
    color: red;
    background: yellow;
}

你会在 FF 和 IE 中看到黄色背景,但在 Chrome 或 Safari 中它看起来很糟糕。

有没有通过css解决的办法?

最佳答案

你可以使用line-height代替height;

Fiddle

CSS

 ::-webkit-input-placeholder { 
    color: red;
    background: yellow;
 }
 :-moz-placeholder { 
   color: red;
   background: yellow;
 }
 ::-moz-placeholder { 
    color: red;
    background: yellow;
 }
 :-ms-input-placeholder { 
    color: red;
    background: yellow;
 }

 input {
    line-height: 50px;
 }

关于css: webkit-input-placeholder 背景色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26804904/

相关文章:

css - 如何为 Ionic 中的每个事件选项卡设置不同的颜色

javascript - 电子邮件中YouTube视频自动播放的HTML代码

javascript - 使用 JQuery 更改父 div 的背景时,子 div 消失

Jquery/CSS - 如何清除我无法编辑的另一个文件中的 CSS 背景集

javascript - D3.js 缩放在 Safari 中无法与鼠标滚轮配合使用

html - webkit-transform 添加到两个不同的复选框时不起作用

html - 使用纯 css 隐藏元素的第一个子元素以外的所有内容

html - 使用 CSS 实现纸张翻转过渡

html - 当我已经在使用背景时,将图像平铺在整个页面上

CSS3 -webkit转换: translateZ(xpx) not working