在浏览器的默认选择文本颜色 - 它是什么? [英] In-browser default selected text color - What is it?

查看:435
本文介绍了在浏览器的默认选择文本颜色 - 它是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假如没有CSS,JavaScript或其它HTML挂羊头卖狗肉,如何在浏览器确定文本与所选文本的颜色和背景是什么?

Supposing no CSS, javascript or other HTML trickery, how does the browser determine the color of the text and background for selected text?

例如,标准的白色背景( #FFFFFF RGB = 255,255,255 )以黑色文本(#000000 RGB = 0,0,0 )时,倒置选择的颜色(即黑色背景白字)。其他颜色是如何选择的?例如,在此网站撰写的问题时,右侧栏的面积怎样问与背景#FFEFC6 文本#AE0000 ,其中选中时成为#3399FF #FFFFFF 分别。

For example, standard white background (#FFFFFF or RGB=255,255,255) with black text (#000000 or RGB=0,0,0) when selected with invert the colors (i.e. black background, white text). How are other colors chosen? For example, when writing a question on this site, the right sidebar has an area "How to ask" with background #FFEFC6 and text #AE0000, which when selected become #3399FF and #FFFFFF respectively.

我想知道这是怎么确定(是否有一个算法或只是默认值),这是一样的跨浏览器?

I would like to know how this is determined (is there an algorithm or just defaults) and is this the same across browsers?

推荐答案

我与约书亚同意颜色来自系统的,但我不同​​意关于CSS,例如,的 CSS-技巧的:

I'd agree with Joshua that the colors come from the system, but I'd disagree about CSS, for example, CSS-Tricks:

::selection { background: #ffcc89; color: #222; }
::-moz-selection { background: #ffcc89; color: #222; }

有关更多信息,请参见怪异模式上选择的样式。

For more info, see Quirksmode on selection styles.

这篇关于在浏览器的默认选择文本颜色 - 它是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆