CSS如何设置鼠标样式?下面本篇文章就来给大家介绍一下使用CSS设置鼠标样式的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

在CSS中,可以使用cursor属性来设置鼠标样式。cursor 属性规定要显示的鼠标(光标)的类型(形状)。
cursor属性定义了鼠标指针放在一个元素边界范围内时所用的光标形状(不过 CSS2.1 没有定义由哪个边界确定这个范围)。
可能的值:
| 值 | 描述 | 
|---|---|
| url | 需使用的自定义光标的 URL。 注释:请在此列表的末端始终定义一种普通的光标,以防没有由 URL 定义的可用光标。 | 
| default | 默认光标(通常是一个箭头) | 
| auto | 默认。浏览器设置的光标。 | 
| crosshair | 光标呈现为十字线。 | 
| pointer | 光标呈现为指示链接的指针(一只手) | 
| move | 此光标指示某对象可被移动。 | 
| e-resize | 此光标指示矩形框的边缘可被向右(东)移动。 | 
| ne-resize | 此光标指示矩形框的边缘可被向上及向右移动(北/东)。 | 
| nw-resize | 此光标指示矩形框的边缘可被向上及向左移动(北/西)。 | 
| n-resize | 此光标指示矩形框的边缘可被向上(北)移动。 | 
| se-resize | 此光标指示矩形框的边缘可被向下及向右移动(南/东)。 | 
| sw-resize | 此光标指示矩形框的边缘可被向下及向左移动(南/西)。 | 
| s-resize | 此光标指示矩形框的边缘可被向下移动(南)。 | 
| w-resize | 此光标指示矩形框的边缘可被向左移动(西)。 | 
| text | 此光标指示文本。 | 
| wait | 此光标指示程序正忙(通常是一只表或沙漏)。 | 
| help | 此光标指示可用的帮助(通常是一个问号或一个气球)。 | 
示例1:
.custom {
  cursor: url(https://img.php.cn/upload/article/000/000/006/5d89c525da790357.png),pointer;
}

示例2:
.auto {
  cursor: auto;
}
.default {
  cursor: default;
}
.none {
  cursor: none;
}

示例3:
.context-menu {
  cursor: context-menu;
}
.help {
  cursor: help;
}
.pointer {
  cursor: pointer;
}
.progress {
  cursor: progress;
}
.wait {
  cursor: wait;
}

示例4:
.cell {
  cursor: cell;
}
.crosshair {
  cursor: crosshair;
}
.text {
  cursor: text;
}
.vertical-text {
  cursor: vertical-text;
}

示例5:
.alias {
  cursor: alias;
}
.copy {
  cursor: copy;
}
.move {
  cursor: move;
}
.no-drop {
  cursor: no-drop;
}
.not-allowed {
  cursor: not-allowed;
}

示例6:
.zoom-in {
  cursor: -webkit-zoom-in;
  cursor: zoom-in;
}
.zoom-out {
  cursor: -webkit-zoom-out;
  cursor: zoom-out;
}

示例7:
.grab {
  cursor: -webkit-grab;
  cursor: grab;
}
.grabbing {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}

示例8:
.n-resize {
  cursor: n-resize;
}
.ne-resize {
  cursor: ne-resize;
}
.e-resize {
  cursor: e-resize;
}
.se-resize {
  cursor: se-resize;
}
.s-resize {
  cursor: s-resize;
}
.sw-resize {
  cursor: sw-resize;
}
.w-resize {
  cursor: w-resize;
}
.nw-resize {
  cursor: nw-resize;
}
.se-resize {
  cursor: se-resize;
}
.ew-resize {
  cursor: ew-resize;
}
.ns-resize {
  cursor: ns-resize;
}
.nesw-resize {
  cursor: nesw-resize;
}
.nwse-resize {
  cursor: nwse-resize;
}
.col-resize {
  cursor: col-resize;
}
.row-resize {
  cursor: row-resize;
}
.all-scroll {
  cursor: all-scroll;
}


