CSS 输入占位符的默认颜色和字体是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41900143/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 12:23:06  来源:igfitidea点击:

What is the default color and font for input placeholders

csstwitter-bootstrap

提问by kevin_b

Does anyone know what is the default color and font and size for placeholders for inputs and textareas?

有谁知道输入和文本区域占位符的默认颜色、字体和大小是什么?

<input type="text" name="input" placeholder="Select data" class="form-control"/>

enter image description here

在此处输入图片说明

回答by random_user_name

Depending on your application / need, you could use a color picker tool, or you could use your Browser's developer console, to be sure. But...

根据您的应用程序/需要,您可以使用颜色选择器工具,或者您可以使用浏览器的开发人员控制台,以确保。但...

The defaultinput placeholder color varies by browser.

默认的输入占位符颜色由浏览器的不同而不同。

In your screenshot, it's #8e8e8e

在你的截图中,它是 #8e8e8e

Some examples by browser:
In Chrome (Mac) it's #a9a9a9
in Firefox (Mac) it's #777777

浏览器的一些示例:
在 Chrome (Mac) 中,#a9a9a9
在 Firefox (Mac) 中,它是#777777

Bootstrap 3 does define a "default" placeholder color, which you can see by inspecting the CSS a variety of ways - below is from the CSS directly (For Bootstrap v3.3.7):

Bootstrap 3 确实定义了一个“默认”占位符颜色,您可以通过多种方式检查 CSS 来查看它 - 以下是直接来自 CSS(对于 Bootstrap v3.3.7):

.form-control::-moz-placeholder{
    color:#999;
    opacity:1
}

.form-control:-ms-input-placeholder{
    color:#999
}

.form-control::-webkit-input-placeholder{
    color:#999
}

So - Bootstrap 3 defines the default placeholder color as #999. (For reference, Bootstrap 4 defines the default placeholder color as #636c72).

因此,Bootstrap 3 将默认占位符颜色定义为#999. (作为参考,Bootstrap 4 将默认占位符颜色定义为#636c72)。

回答by Jordan.J.D

If you open up bootstrap.cssfile, and ctrl+f(find) and search for "form-control" and look for placeholder you will find:

如果您打开bootstrap.css文件,然后ctrl+ f(查找)并搜索“表单控件”并查找占位符,您会发现:

  .form-control::-moz-placeholder {
  color: #999;
  opacity: 1;
}
.form-control:-ms-input-placeholder {
  color: #999;
}
.form-control::-webkit-input-placeholder {
  color: #999;
}

According to bootstraps documentation:

根据引导程序文档

Bootstrap's global default font-size is 14px, with a line-height of 1.428. This is applied to the and all paragraphs. In addition,

(paragraphs) receive a bottom margin of half their computed line-height (10px by default).

Bootstrap 的全局默认字体大小为 14px,行高为 1.428。这适用于所有段落。此外,

(段落)的底部边距为其计算行高的一半(默认为 10 像素)。

link to color

颜色链接