Change color of selection

后端 未结 3 1874
不思量自难忘°
不思量自难忘° 2020-12-10 16:15

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

3条回答
  •  北海茫月
    2020-12-10 16:53

    You are looking for the selection pseudo-element.

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

    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.

提交回复
热议问题