Home > Web Front-end > JS Tutorial > cursor cursor style is replaced by pictures

cursor cursor style is replaced by pictures

巴扎黑
Release: 2017-07-24 14:31:26
Original
2306 people have browsed it

The mouse cursor style is limited, please refer to it. You can customize the cursor style by setting cursor:url('xxx.cur',auto;), but it always does not take effect. I don’t know why. then what should we do? Another way is to use a picture to replace the mouse cursor. Here's how to use it.

1. Make a cursor picture (PS and other tools), be careful not to use a white background, use a transparent background. The transparent background is usually a gif or png format image.

Picture 1 The arrow picture I made is 32*32px

2. Use a span tag to include it Picture

<span style="color: #0000ff"><</span><span style="color: #800000">span </span><span style="color: #ff0000">id</span><span style="color: #0000ff">="cursorLRArrow"</span><span style="color: #ff0000"> style</span><span style="color: #0000ff">="display:none;position:absolute;z-index:9998;width:32px;height:32px;background-image:url(&#39;left_right_arrow_32.gif&#39;);cursor:none;pointer-events:none"</span><span style="color: #0000ff">><br></</span><span style="color: #800000">span</span><span style="color: #0000ff">></span>
Copy after login

Style attribute explanation

display:none is not displayed initially

position:absolute Absolute positioning, control the position with left and top, relative inclusion (position: relative/absolute) The position of the parent element positioned in this way. If no such parent element can be found, it will be relative to the body

z-index:9998 layer height. The higher it is, the less it will be blocked. The highest Set the same width and height as the picture for 2147483647

width,height

background-imageSet the picture

cursor:none The mouse cursor is not displayed

pointer- events:none does not respond to mouse events. Events can penetrate this layer and thus will not affect the response of underlying elements to mouse events

3. Replacement of mouse cursor

$('body').mousemove( x = e.pageX;  y = e.pageY; ).css('cursor','none''#cursorLRArrow''inline-block'-15)+'px'-10)+'px''#cursorLRArrow'
Copy after login

The above is the detailed content of cursor cursor style is replaced by pictures. For more information, please follow other related articles on the PHP Chinese website!

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