尝试设置占位符背景颜色。在我尝试增加输入字段高度之前,它工作正常。在 mozilla 和 ie 中,占位符背景填充输入中的所有空间。但在 webkit 背景中,仅为占位符文本高度设置。
这是一个例子:http://jsfiddle.net/3zp36wL7/2/
::-webkit-input-placeholder {
color: red;
background: yellow;
}
你会在 FF 和 IE 中看到黄色背景,但在 Chrome 或 Safari 中它看起来很糟糕。
有没有通过css解决的办法?
最佳答案
你可以使用line-height
代替height
;
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/