Get default selection color?

后端 未结 2 1119
陌清茗
陌清茗 2021-01-07 07:37

I can change the CSS selection color, but how can I get the browser/OS default selection so that I can use it elsewhere?

e.g. on Ubuntu+Chrome text is highl

相关标签:
2条回答
  • 2021-01-07 07:53

    In the CSS2 specs some color keywords are defined but are now deprecated. Yet they should still work just fine:

    .selected {
      background: Highlight;
      color: HighlightText;
    }
    <p>Lorem ipsum with some <span class="selected">selected text</span></p>

    0 讨论(0)
  • 2021-01-07 07:54

    I think that for what you want is better if you use Javacript combined with CSS.

    You could check this post https://stackoverflow.com/a/11752084/8379001 that shows how to find out the os and applies it to CSS.

    0 讨论(0)
提交回复
热议问题