【问题标题】:CSS: Why Color code #999 shades are different in Chrome and Firefox? [duplicate]CSS:为什么颜色代码 #999 的颜色在 Chrome 和 Firefox 中不同? [复制]
【发布时间】:2019-11-11 20:09:27
【问题描述】:

我需要更改 HTML5 输入占位符样式,如下所示。

input[type="text"]#myInput::placeholder {
font-size: 13px;
  font-family: helvetica;
  color: #999;
  font-weight: 400;
}

在上面的 sn-p 中,我使用了 #999 色度,但它在 chrome 和 IE 中看起来很像,在 Firefox 中看起来很浅。

我的示例代码在这里:https://codepen.io/JGSpark/pen/MMQxER?&editable=true

请先在 Chrome 中尝试,然后再在 Firefox 中尝试。

P.S:我使用的是 Chrome 75+、Firefox 67+、IE11

谁能帮我让这个在所有浏览器中看起来都相似?

【问题讨论】:

标签: html css google-chrome firefox


【解决方案1】:

Firefox 19 及更高版本默认将 40% (0.4) 的不透明度应用于占位符文本。只需添加 opacity: 1;

input:-moz-placeholder,
input::-moz-placeholder {
    opacity: 1 !important;
}

【讨论】:

  • 这个答案还可以,但 Firefox 已经支持标准(无前缀)语法已有几年了。
猜你喜欢
  • 2021-10-01
  • 2012-11-02
  • 2011-05-20
  • 1970-01-01
  • 1970-01-01
  • 2013-01-21
  • 1970-01-01
  • 1970-01-01
  • 2020-06-13
相关资源
最近更新 更多