更改选择的颜色 [英] Change color of selection

查看:76
本文介绍了更改选择的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您在浏览器中选择文字时,大多数情况下背景背后的文字会变为蓝色。如何将此颜色更改为另一种颜色?

When you select text in browser, most often background behind text being selected changes color to blue. How to change this color to another?

推荐答案

您正在查找 c>伪元素。

You are looking for the selection pseudo-element.

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

另外,如果你打算在你的网站使用文本阴影,我建议添加 text-shadow:none; 到你的 :: selection 样式。正如您可以在这个小提示中看到的,它真的很难在眼睛。

Also, as a side note. If you plan on using text-shadow in your site at all, I would recommend adding text-shadow:none; to your ::selection styling. As you can see in this fiddle, it is really hard on the eyes.

这篇关于更改选择的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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