Home>Article>Web Front-end> How to modify cursor color in css

How to modify cursor color in css

青灯夜游
青灯夜游 Original
2021-07-22 17:14:49 5838browse

Method: 1. Use the caret-color attribute, the syntax "caret-color: color value;"; 2. Use the "::first-line" selector, the syntax "input{color: cursor color value;" }input::first-line{color: text color value;}".

How to modify cursor color in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

There are two commonly used methods to change the color of the insertion cursor in CSS:

Method 1: Use the caret-color attribute

The caret-color attribute specifies the color of the cursor (caret) in input, textareas, or any editable element.

Example:

    




Rendering:

How to modify cursor color in css

##caret-color attribute Currently, Chrome and Firefox can basically use it with confidence. But Safari and IE browsers still need to wait for some time.

Method 2: Use the ::first-line selector

Yes

    


Rendering:


How to modify cursor color in css

The method of using ::first-line pseudo-element performs well under Chrome and Safari browsers, but Firefox browser does not support it

Compatibility method:

input { color: #333; caret-color: red; } @supports (-webkit-mask: none) and (not (cater-color: red)) { input { color: red; } input::first-line { color: #333; } }

(Learning video sharing:

css video tutorial

The above is the detailed content of How to modify cursor color in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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