龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > div+css/html >

CSS教程之:CSS光标

时间:2009-12-21 11:47来源:未知 作者:admin 点击:
分享到:
通过cursor属性,我们可以让光标移动到元素上之后,显示出不同的形状。 一个很好的例子就是:通常,当光标移动到一个链接上之后,光标会变成“小手”的形状。但在对于表单的提交
通过cursor属性,我们可以让光标移动到元素上之后,显示出不同的形状。

一个很好的例子就是:通常,当光标移动到一个链接上之后,光标会变成“小手”的形状。但在对于表单的提交按钮,光标放上去之后却没什么变化。如果能够让光标移动到提交按钮上之后,变成“小手”的形状,就会给使用者一个更明显的提示。

下面的列表显示了能够用于cursor属性的可选值:
可选值 说明
auto 有浏览器决定光标形状
crosshair 十字/td>
default 箭头
pointer 小手
move 四个方向带箭头的十字
e-resize 水平方向箭头
ne-resize 东北方向箭头
nw-resize 西北方向箭头
n-resize 垂直方向箭头
se-resize 东南方向箭头
sw-resize 西南方向箭头
s-resize 垂直方向箭头
w-resize 水平方向箭头
text I形光标
wait 沙漏
help 问号标记
url 指定光标图片

注意:当改变光标形状时,要考虑到一般的使用习惯。例如,如果用户将光标移动到链接上之后,变成了十字交叉形,就会让人迷惑。

例子:
<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>
精彩图集

赞助商链接