|
我们在网页设计的时候,为了达到个性效果,需要将系统默认的鼠标形状改变掉,自宝义鼠标显示的形状,我们以前可以用javascript来实现。现在我们完全可以用css来实现这一个性效果了。
CSS有一个属性:cursor,其作用是设置或检索在对象上移动的鼠标指针采用何种系统预定义的光标形状。更多关于cursor请参考这里。
我们看下面的实例,更好的理解如何用CSS自定义鼠标显示的形状。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>www.xxcss.com</title> <style type="text/css"> <!-- span {display:block;line-height:30px;margin:5px 0;background:#f0f0f0;text-align:center;} --> </style> </head> <body> <span style="cursor:hand;">hand 手型</span> <span style="cursor:crosshair;">crosshair 十字</span> <span style="cursor:text;">text 文本</span> <span style="cursor:wait;">wait 等待</span> <span style="cursor:help;">help 问号</span> <span style="cursor:e-resize;">e-resize 右的箭头</span> <span style="cursor:ne-resize;">ne-resize 右上的箭头</span> <span style="cursor:n-resize;">n-resize 上的箭头</span> <span style="cursor:nw-resize;">nw-resize 左上的箭头</span> <span style="cursor:w-resize;">w-resize 左的箭头</span> <span style="cursor:sw-resize;">sw-resize 左下的箭头</span> <span style="cursor:s-resize;">s-resize 下的箭头</span> <span style="cursor:se-resize;">se-resize 右下的箭头</span> <span style="cursor:move;">move 移动</span> </body> </html>
|