Changing the highlight color when selecting text in an HTML text input

后端 未结 10 1105
有刺的猬
有刺的猬 2020-11-30 00:07

I\'ve been looking for this throughout the web and can\'t even find anyone else even asking this, let alone a solution...

Is there a way to change the color of the h

10条回答
  •  广开言路
    2020-11-30 00:53

    I guess this can help :

    selection styles

    It's possible to define color and background for text the user selects.

    Try it below. If you select something and it looks like this, your browser supports selection styles.

    This is the paragraph with normal ::selection.

    This is the paragraph with ::-moz-selection.

    This is the paragraph with ::-webkit-selection.

    Testsheet:

    p.normal::selection {
      background:#cc0000;
      color:#fff;
    }
    
    p.moz::-moz-selection {
      background:#cc0000;
      color:#fff;
    }
    
    p.webkit::-webkit-selection {
      background:#cc0000;
      color:#fff;
    }
    

    Quoted from Quirksmode

提交回复
热议问题