占位符不在firefox中工作

时间:2012-11-15 06:00:21

标签: jquery html css

.txt1::-webkit-input-placeholder::before {
       color:#c2c3c3;
       content:"Hey Brad,\A Tell us what's on your mind";
    }
    .txt1::-moz-input-placeholder::before {
       color:#c2c3c3;
       content:"Hey Brad,\A Tell us what's on your mind";
    }

占位符不在Firefox中工作,Chrome很好

3 个答案:

答案 0 :(得分:2)

Webkit使用::-webkit-input-placeholder来定位占位符文本:

.txt1::-webkit-input-placeholder:before {
    color:#c2c3c3;
    content:"Hey Brad,\A Tell us what's on your mind";
}

Firefox使用:-moz-placeholder定位占位符文字:

.txt1:-moz-placeholder:before {
    color:#c2c3c3;
    content:"Hey Brad,\A Tell us what's on your mind";
}

您已将input添加到Firefox的选择器中,这是不需要的。您应该只在Firefox的选择器的开头包含一个冒号,而不是两个。我还建议在选择器::before之后删除额外的冒号,并将其更改为:before,因为这些是不必要的。使用上面的代码示例,你应该很好。希望这可以帮助!如果您有疑问,请告诉我。

来源:https://developer.mozilla.org/en-US/docs/CSS/:-moz-placeholder

答案 1 :(得分:0)

尝试一下:

.txt1::-moz-placeholder::before {
  color:#c2c3c3;
  content:"Hey Brad,\A Tell us what's on your mind";
}

我认为input

中不应删除-moz-input-placeholder

答案 2 :(得分:0)

为什么不在input代码中添加占位符?例如:

input type="" placeholder="any text"
相关问题