Home  >  Article  >  Web Front-end  >  css mouse style

css mouse style

藏色散人
藏色散人Original
2021-01-29 16:23:248336browse

In CSS, you can set the mouse style through the cursor attribute. The implementation method is as follows: first create an HTML sample file; then define some span tags, and add style attributes to the span tags respectively; finally, set different Just use the cursor attribute value to implement different mouse styles.

The operating environment of this article: Acer S40-51, Windows10 Home Chinese version, HTML5&&CSS3&&HBuilderX.3.0.5

Recommended: "css video tutorial"

css writing mouse style

When we layout DIV CSS, we will encounter the control of the mouse pointer within the object, such as the mouse passing through the pointer and changing into a finger shape, etc. Next we introduce the mouse pointer style cursor control. In addition to the system default mouse pointer style, you can set the image as the mouse pointer through CSS. It is common for some websites to have various small image styles for the mouse pointer. Of course, this is to set the mouse style through css cursor.

1. Cursor syntax:

cursor : auto | crosshair | default | hand | move | help 
| wait | text | w-resize |s-resize | n-resize |e-resize 
| ne-resize |sw-resize | se-resize | nw-resize |pointer 
| url (url)

Commonly used cursor cursor description

1. div{ cursor:default}default normal mouse pointer

2. div{ cursor:hand } and div{ cursor:text } text selection effect

3. div{ cursor:move } movement selection effect

4. div{ cursor:pointer } Finger shape link selection effect

5, div{ cursor:url(url image address) } Set the object to the picture

2, cursor style effect diagram

css mouse style

3. Mouse pointer description

cursor sets or retrieves the system predefined cursor shape used by the mouse pointer moving on the object.

4. Layout structure

p { cursor: text; } /* css注释: 设置鼠标移动到html p对象时鼠标变为文本选择样式 */
a { cursor: pointer; } /* css注释: 设置鼠标移动到a超链接对象时鼠标变为手指形状(链接选择) */
body { cursor: url("小图片地址")} /* 设置鼠标指针默认为一个小图片 */

Some code examples for different cursors:




    
    css鼠标样式

请把鼠标移动到单词上,可以看到鼠标指针发生变化:

auto:默认,浏览器设置的光标。
crosshair:光标呈现为十字线。
default:默认光标(通常是一个箭头)
e-resize:此光标指示矩形框的边缘可被向右(东)移动。
help:此光标指示可用的帮助(通常是一个问号或一个气球)。
move:此光标指示某对象可被移动。
n-resize:此光标指示矩形框的边缘可被向上(北)移动。
ne-resize:此光标指示矩形框的边缘可被向上及向右移动(北/东)。
nw-resize:此光标指示矩形框的边缘可被向上及向左移动(北/西)。
pointer:光标呈现为指示链接的指针(一只手)
progress
s-resize:此光标指示矩形框的边缘可被向下移动(南)。
se-resize:此光标指示矩形框的边缘可被向下及向右移动(南/东)。
sw-resize:此光标指示矩形框的边缘可被向下及向左移动(南/西)。
text:此光标指示文本。
w-resize:此光标指示矩形框的边缘可被向左移动(西)。
wait:此光标指示程序正忙(通常是一只表或沙漏)。

For more computer programming related knowledge, please visit:ProgrammingTeaching! !

The above is the detailed content of css mouse style. 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