html - 占位符不适用于输入,在 Firefox 中具有类型 ='number'

标签 html css firefox placeholder

这是我的示例代码:

<!DOCTYPE html>
<html>
<head>
    <title>«Bug»</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width">
    <style type="text/css">
        input[type='number'] {
            background: gray;
        }
        input[type='number']::-webkit-input-placeholder {
            color: red;
        }
        input[type='number']::-moz-placeholder {
            color: red;
        }
        input[type='number']:-ms-input-placeholder {
            color: red;
        }
        input[type='number']::placeholder {
            color: red;
        }
    </style>
</head>
<body style="width: 100%; height: 100vh; display: flex; justify-content: center; align-items: center;">
    <input type="number" placeholder="buggy bug">
</body>
</html>

您也可以在这里查看:http://g1un.ru/bug/bug.html
我也做了“笔”http://codepen.io/g1un/pen/GmzaEg但它有时会正常工作,当通过第一个链接时它总是有问题。
我正在尝试使用 type='number' 设置输入占位符的样式。但在 firefox (53.0.3) 中没有效果。
请帮忙。

最佳答案

在你的 codepen 中,在 CSS cog 中打开 autoprefixer。

input[type='number'] {
  background: gray;
  &::placeholder {
    color: red;
  }
}

键入此 - 然后查看带有 V 的 CSS Pane 的 CSS 输出图标。

这将帮助您看到正确的前缀。

input[type='number'] {
  background: gray;
}
input[type='number']::-webkit-input-placeholder {
  color: red;
}
input[type='number']::-moz-placeholder {
  color: red;
}
input[type='number']:-ms-input-placeholder {
  color: red;
}
input[type='number']::placeholder {
  color: red;
}

另一个注意事项 - 在上面的示例中,您的 <style>标记应在 <head> 中-

关于html - 占位符不适用于输入,在 Firefox 中具有类型 ='number',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44164772/

相关文章:

html - IFrame 现在应该死了吗?

html - Bootstrap 尝试将 Logo 向左对齐并将其居中

隐藏后的 CSS 无限动画未重置(Chrome)

html - 如何流畅的做完不间断的CSS动画

javascript - 防止 Firefox 中的默认 Tab 键行为

html - 从 html 按钮溢出的文本似乎与应用的样式形成对比

css - Div 宽度对我不起作用

html - 定义标题标签之间的行距

javascript - SoundJS:Firefox 无法播放 mp3

javascript - 使用 HTML/JavaScript 检测本地文件拖放