CSS的 cursor 属性允许您指定应该向用户显示的光标类型.
此属性的一个很好的用法是使用图像提交表单上的按钮.默认情况下,当光标悬停在链接上时,光标会从指针变为手形.但是,它不会更改表单上的提交按钮的形式.因此,只要有人将鼠标悬停在作为提交按钮的图像上,就会提供图像可点击的直观线索.
下表显示了光标属性的可能值 :
Sr.No. | Value&说明 |
---|---|
1 | auto 光标的形状取决于它结束的上下文区域.例如,我在文本上,交出链接等等...... |
2 | crosshair 十字准线或加号 |
3 | default 箭头 |
4 | 指针 指针(在IE 4中这个值是手) |
5 | move I栏 |
6 | e-resize 光标表示框的边缘是向右移动(东) |
7 | ne-resize 光标指示框的边缘向上和向右移动(北/东) |
8 | nw-resize 光标指示是一个盒子的边缘向上和向左移动(北/西) |
9 | n-resize 光标表示方框的边缘是向上移动(北) |
10 | se-resize 光标指示框的边缘向下和向右移动(南/东) |
11 | sw-resize 光标指示框的边缘向下和向左移动(南/西) |
12 | s-resize 光标指示框的边缘向下移动(向南) |
13 | w-resize 光标指示框的边缘向左(向西)移动 |
14 | text I栏 |
15 | wait 小时沙漏 |
16 | help 问号或气球,非常适合在帮助按钮上使用 |
17 | < url> 光标图像文件的来源 |
注意 : 您应该尝试仅使用这些值为用户添加有用的信息,并且在某些地方,他们希望看到该光标.例如,当某人悬停在链接上时使用十字准线可能会使访问者感到困惑.
这是一个示例 :
<html> <head> </head> <body> <p>Move the mouse over the words to see the cursor change:</p> <div style = "cursor:auto">Auto</div> <div style = "cursor:crosshair">Crosshair</div> <div style = "cursor:default">Default</div> <div style = "cursor:pointer">Pointer</div> <div style = "cursor:move">Move</div> <div style = "cursor:e-resize">e-resize</div> <div style = "cursor:ne-resize">ne-resize</div> <div style = "cursor:nw-resize">nw-resize</div> <div style = "cursor:n-resize">n-resize</div> <div style = "cursor:se-resize">se-resize</div> <div style = "cursor:sw-resize">sw-resize</div> <div style = "cursor:s-resize">s-resize</div> <div style = "cursor:w-resize">w-resize</div> <div style = "cursor:text">text</div> <div style = "cursor:wait">wait</div> <div style = "cursor:help">help</div> </body> </html>
它将产生以下结果 :