cursor

Avatar of Sara Cope
Sara Cope on

DigitalOcean 提供适用于您旅程每个阶段的云产品。 立即开始使用 价值 200 美元的免费信用额度!

CSS 中的 cursor 属性控制鼠标指针位于设置此属性的元素上时的外观。 显然,这仅与存在鼠标和指针的浏览器/操作系统相关。 它们本质上用于 UX,传达某些功能的概念。 因此,请尽量不要破坏这种功能。

有很多这样的光标

.auto            { cursor: auto; }
.default         { cursor: default; }
.none            { cursor: none; }
.context-menu    { cursor: context-menu; }
.help            { cursor: help; }
.pointer         { cursor: pointer; }
.progress        { cursor: progress; }
.wait            { cursor: wait; }
.cell            { cursor: cell; }
.crosshair       { cursor: crosshair; }
.text            { cursor: text; }
.vertical-text   { cursor: vertical-text; }
.alias           { cursor: alias; }
.copy            { cursor: copy; }
.move            { cursor: move; }
.no-drop         { cursor: no-drop; }
.not-allowed     { cursor: not-allowed; }
.all-scroll      { cursor: all-scroll; }
.col-resize      { cursor: col-resize; }
.row-resize      { cursor: row-resize; }
.n-resize        { cursor: n-resize; }
.e-resize        { cursor: e-resize; }
.s-resize        { cursor: s-resize; }
.w-resize        { cursor: w-resize; }
.ns-resize       { cursor: ns-resize; }
.ew-resize       { cursor: ew-resize; }
.ne-resize       { cursor: ne-resize; }
.nw-resize       { cursor: nw-resize; }
.se-resize       { cursor: se-resize; }
.sw-resize       { cursor: sw-resize; }
.nesw-resize     { cursor: nesw-resize; }
.nwse-resize     { cursor: nwse-resize; }

光标也可以是图像

.custom {
  /* The second value here is a fallback. */
  cursor: url(images/my-cursor.png), auto;

  /* You may need coordinates to adjust the pointer
     for example, the custom cursor is circular and you want
     the middle to be where you click */
  cursor: url(target.svg) 15 15, move;
}

一些 WebKit 专用的光标

-webkit-zoom-in
-webkit-zoom-out
-webkit-zoom-grab
-webkit-zoom-grabbing

更多信息

浏览器支持

此浏览器支持数据来自 Caniuse,其中包含更多详细信息。 数字表示浏览器从该版本开始支持该功能。

桌面

ChromeFirefoxIEEdgeSafari
549145

移动设备/平板电脑

Android ChromeAndroid FirefoxAndroidiOS Safari
127127

对于较新的值,例如 zoom-inzoom-out

此浏览器支持数据来自 Caniuse,其中包含更多详细信息。 数字表示浏览器从该版本开始支持该功能。

桌面

ChromeFirefoxIEEdgeSafari
4*2*123.1*

移动设备/平板电脑

Android ChromeAndroid FirefoxAndroidiOS Safari
127127