目录
一、CSS cursor 属性值:
属性值 | 示意图 | 描述 |
auto | 默认值,由浏览器根据当前上下文确定要显示的光标样式 | |
default | ![]() |
默认光标,不考虑上下文,通常是一个箭头 |
none | 不显示光标 | |
initial | 将此属性设置为其默认值 | |
inherit | 从父元素基础 cursor 属性的值 | |
context-menu | ![]() |
表示上下文菜单可用 |
help | ![]() |
表示有帮助 |
pointer | ![]() |
表示一个链接 |
progress | ![]() |
进度指示器,表示程序正在执行一些处理,但是您仍然可以在该界面进行一些操作(与 wait 不同) |
wait | ![]() |
表示程序繁忙,您应该等待程序指向完成 |
cell | ![]() |
表示可以选择一个单元格(或一组单元格) |
crosshair | ![]() |
表示一个十字准线 |
text | ![]() |
表示可以选择的文本 |
vertical-text | ![]() |
表示可以选择的垂直文本 |
alias | ![]() |
表示要创建别名或快捷方式 |
copy | ![]() |
表示可以复制某些内容 |
move | ![]() |
表示可以移动鼠标下方的对象 |
no-drop | ![]() |
表示所拖动的项目不能放置在当前位置 |
not-allowed | ![]() |
表示无法完成某事 |
all-scroll | ![]() |
表示对象可以沿任何方向滚动(平移) |
col-resize | ![]() |
表示可以水平调整列的大小 |
row-resize | ![]() |
表示可以垂直调整行的大小 |
n-resize | ![]() |
表示对象的边缘可以向上(向北)移动 |
e-resize | ![]() |
表示对象的边缘可以向右(向东)移动 |
s-resize | ![]() |
表示对象的边缘可以向下(向南)移动 |
w-resize | ![]() |
表示对象的边缘可以向左(向西)移动 |
ne-resize | ![]() |
表示对象的边缘可以向上和向右(北/东)移动 |
nw-resize | ![]() |
表示对象的边缘可以向上和向左(北/西)移动 |
se-resize | ![]() |
表示对象的边缘可以向下和向右(向南/向东)移动 |
sw-resize | ![]() |
表示对象的边缘可以向下和向左(南/西)移动 |
ew-resize | ![]() |
表示可以双向调整对象大小的光标 |
ns-resize | ![]() |
|
nesw-resize | ![]() |
|
nwse-resize | ![]() |
|
zoom-in | ![]() |
表示可以放大某些内容 |
zoom-out | ![]() |
表示可以缩小某些内容 |
grab | ![]() |
表示可以抓取(拖动)某些东西 |
grabbing | ![]() |
表示已经抓取到某些东西 |
url("") | 自定义光标的样式,括号中的内容为光标图像的源文件路径 |
提示:由于计算机系统的不同,鼠标的样式会存在一定的差异。
二、常用案例:
<!DOCTYPE html>
<html>
<head>
<style>
div {
line-height: 50px;
border: 1px solid #0ff;
margin-top: 10px;
padding-left: 20px;
}
.pointer {
cursor: pointer;
}
.progress {
cursor: progress;
}
.wait {
cursor: wait;
}
.text {
cursor: text;
}
.move {
cursor: move;
}
.not-allowed {
cursor: not-allowed;
}
.all-scroll {
cursor: all-scroll;
}
.zoom-in {
cursor: zoom-in;
}
.zoom-out {
cursor: zoom-out;
}
.grab {
cursor: grab;
}
</style>
</head>
<body>
<div class="pointer">cursor: pointer;</div>
<div class="progress">cursor: progress;</div>
<div class="wait">cursor: wait;</div>
<div class="text">cursor: text;</div>
<div class="move">cursor: move;</div>
<div class="not-allowed">cursor: not-allowed;</div>
<div class="all-scroll">cursor: all-scroll;</div>
<div class="zoom-in">cursor: zoom-in;</div>
<div class="zoom-out">cursor: zoom-out;</div>
<div class="grab">cursor: grab;</div>
</body>
</html>