Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you implement a grabbing cursor icon in Chrome?

I know it's possible to use a grabbing cursor icon in Chrome (in Gmail, of course), but I can't figure out how to implement it in my code. I have tried (in CSS):

body {
  cursor: grab;
}

body {
  cursor: -webkit-grab;
}


body {
  cursor: url(http://www.worldtimzone.com/mozilla/testcase/css3cursors_files/grab.gif);
}
like image 275
Alex Avatar asked Sep 03 '10 01:09

Alex


People also ask

How do you drag a cursor?

To move an object, place the mouse cursor over it, press and hold down the left mouse button, then move the mouse while still holding down the left mouse button. When you have "dragged" the object to the location you want, let go of the mouse button.


3 Answers

Chrome Requires -webkit- before the "grab" name;

Here's an example of a style that works with both Chrome and Mozilla, and includes the change in cursor for when you are "holding" something.

#eA { cursor: -webkit-grab; cursor:-moz-grab; }
#eA:active { cursor: -webkit-grabbing; cursor:-moz-grabbing;}

Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor

like image 186
Ulad Kasach Avatar answered Oct 22 '22 14:10

Ulad Kasach


Here's the styling that gmail uses if that's the exact cursor style you're after:

body {
  cursor: url(https://ssl.gstatic.com/ui/v1/icons/mail/images/2/openhand.cur), default !important;
}

You can test it out here.

like image 28
Nick Craver Avatar answered Oct 22 '22 13:10

Nick Craver


So in CSS you start with the basics and move to the more obscure. The browser will pick the last one that works for that specific browser. Chrome, for whatever reason, supports webkit-grab but not grab.

body {
  cursor: pointer;
  cursor: hand;
  cursor: -webkit-grab;
  cursor: grab;
}

Regarding your follow-up question about the ability to manipulate this, please try using something like the following:

document.body.style.cursor = 'move';
like image 14
Nicholas Blasgen Avatar answered Oct 22 '22 15:10

Nicholas Blasgen