CSS3 ::selection behaves differently in FF & Chrome

前端 未结 2 1794
耶瑟儿~
耶瑟儿~ 2020-11-30 06:46

I\'m experimenting with the ::selection pseudo-element in CSS3. In Firefox it works and looks great. My site has a dark navy blue background.

I set the

2条回答
  •  执笔经年
    2020-11-30 07:07

    For some reason Chrome forces it to be semi-transparent. However, you can get around this by setting the background using rgba. I have set the alpha value to be just 0.01 less than 1. Live example: http://jsfiddle.net/tw16/m8End/

    p::-moz-selection {
        background:rgba(255, 255, 125, 0.99);
        color:#032764;
    }
    p::-webkit-selection {
        background:rgba(255, 255, 125, 0.99);
        color:#032764;
    }
    p::selection {
        background:rgba(255, 255, 125, 0.99);
        color:#032764;
    }
    

提交回复
热议问题