CSS3::selection selector_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:39:13
Original
1016 people have browsed it

I have seen that the color and background color of selected content on some websites are not the usual blue and white. I was interested in checking it out today. It turned out to be a very simple usage of CSS3 selector::selection.

Example above:

<style>        .selectColor::selection{color:#fff;background:pink;}        .selectColor::-moz-selection{color:#fff;background:pink;}        .selectColor::-webkit-selection{color:#fff;background:pink;}</style><body>    <p>普通文本,不设置::section,选中时文本的颜色为白色,背景色为蓝色</p>    <p class="selectColor">选择文本的颜色为白色,背景色为粉色</p></body>
Copy after login

Only a few CSS properties can be applied to the ::selection selector: color, background, cursor and outline .

Browser support:

The ::selection selector is supported in IE9, Opera, Google Chrome and Safari.

Firefox supports alternative ::-moz-selection.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template