Html 选择文本时浏览器的默认背景颜色是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16094837/
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-29 07:40:14  来源:igfitidea点击:

What is the browser-default background color when selecting text?

htmlcss

提问by Fellow Stranger

When you select text in a webpage, the background gets a default blue color. What exact color code does this blue color have?

当您在网页中选择文本时,背景会变为默认的蓝色。这种蓝色有什么确切的颜色代码?

回答by Charlie

  1. Safari 6.0.3 Mac*: #B4D5FE
  2. Chrome 26.0.1410.65 Mac*: #ACCEF7
  3. Firefox 19.0 Mac*: #B4D5FF
  4. Chrome 26.0.1410.64 m Windows 8+: #3297FD
  5. Firefox 20.0.1 Windows 8+: #3399FF
  6. Safari 5.1.7 Windows 8+: #3298FD
  7. Internet Explorer 10.0.4 Windows 8+: #3399FF
  1. Safari 6.0.3 Mac *#B4D5FE
  2. Chrome 26.0.1410.65 Mac *#ACCEF7
  3. 火狐 19.0 Mac *#B4D5FF
  4. 铬 26.0.1410.64 米 Windows 8 +#3297FD
  5. 火狐 20.0.1 Windows 8 +#3399FF
  6. Safari 5.1.7 Windows 8 +#3298FD
  7. Internet Explorer 10.0.4 Windows 8 +#3399FF

*Found using ColorSnapper for Mac+Found using ColorSchemer for Windows

*使用适用于 Mac 的 ColorSnapper 找到+使用适用于 Windows 的 ColorSchemer 找到

And here's a screenshot of that information with the hex color codes highlighted in the same color:

这是该信息的屏幕截图,其中十六进制颜色代码以相同颜色突出显示:

Screenshot of hex color codes highlighted in same color

Screenshot of hex color codes highlighted in same color



This will be a never ending list, however, since each...

然而,这将是一个永无止境的清单,因为每个……

  1. Browser
  2. Operating System
  3. Browser Version (maybe)
  1. 浏览器
  2. 操作系统
  3. 浏览器版本(可能)

...will have a different color. Also, as of CSS3, you can change the color using:

...会有不同的颜色。此外,从 CSS3 开始,您可以使用以下方法更改颜色:

::selection{
    background-color:#000;
}

回答by chrx

The ::selection CSS pseudo-elementapplies rules to the portion of a document that has been highlighted (e.g., selected with the mouse or another pointing device) by the user.

::选择CSS伪元素应用规则到已经强调了一个文件的一部分(例如,使用鼠标或其他指针设备选择)由该用户。

The default depends on the browser you are using. It's usually somewhere around #3297fd.

默认值取决于您使用的浏览器。它通常在附近的某个地方#3297fd

You can change it like so:

你可以像这样改变它:

/* draw any selected text yellow on red background */
::-moz-selection { color: gold;  background: red; }
::selection      { color: gold;  background: red; } 

/* draw selected text in a paragraph white on black */
p::-moz-selection { color: white;  background: black; }
p::selection      { color: white;  background: black; }

回答by Zaid Crouch

The selection background colour? That doesn't really have anything to do with the browser, it's an OS setting (and is generally customizable). If you really want to know the specific blue on your machine, screen cap it and open it in any graphics program that lets you inspect colour.

选择背景颜色?这与浏览器没有任何关系,它是一个操作系统设置(并且通常是可定制的)。如果您真的想知道机器上的特定蓝色,请对其进行屏蔽并在任何可以检查颜色的图形程序中打开它。