在网页中,选中某段文字,默认的显示效果为:
能够看到,选中后文字颜色为白色,背景为蓝色。
现咱们想设置,选中后文字为红色,背景为黄色。须要用到CSS伪类 ::selection。
IE9+、Opera、Google、Chrome、Safari都支持 ::selection 选择器。
Firefox 经过其私有属性 :: moz-selection 支持。
设置CSS为:
页面效果为:
扩展:
::selection 能够应用的属性有:color、background、cursor、outline。spa