Hide cursor in Chrome (and IE)

后端 未结 6 1846
南笙
南笙 2021-02-04 04:09

I have the following CSS that hides the mouse cursor for anything on the web page. It works perfectly in Firefox, but in IE and Chrome, it doesn\'t work.

html {
         


        
相关标签:
6条回答
  • 2021-02-04 04:25

    So the best way to deal with this now is the pointer lock api.

    https://developer.mozilla.org/en-US/docs/WebAPI/Pointer_Lock

    It'll hide the mouse cursor, but give you access to the data about mouse movement as well.

    0 讨论(0)
  • 2021-02-04 04:27

    Finding something that works across browsers is a pain.

    The code below works on Chrome, IE, and Firefox. IE likes .cur files, Chrome likes the embedded png, and some browsers actually respect the none :)

    div {
        cursor: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjbQg61aAAAADUlEQVQYV2P4//8/IwAI/QL/+TZZdwAAAABJRU5ErkJggg=='),
        url(images/blank.cur),
        none;
    }
    
    0 讨论(0)
  • 2021-02-04 04:39

    In css: * { cursor: url(cursor.png), none !important }

    0 讨论(0)
  • 2021-02-04 04:44

    Use a hidden applet with the java.awt.robot class to move the cursor off the sreen. Say the very lower left corner.

    0 讨论(0)
  • 2021-02-04 04:45

    I had the same problem in these days and found a good solution to hide the pointer in Google Chrome.

    This is the W3C definition of url property:

    A comma separated of URLs to custom cursors. Note: Always specify a generic cursor at the end of the list, in case none of the URL-defined cursors can be used

    So, you can define a url to not completely transparent image, followed by the default pointer:

    cursor: url(img/almost_transparent.png), default;
    

    If you choose a totally transparent png, Chrome will display a black rectangle instead, but if you choose a png with at least 1px not transparent it will work, and nobody will notice the pointer.

    0 讨论(0)
  • 2021-02-04 04:46

    This property cursor:none; isn't part of the standard

    See here w3c cursor CSS properties.

    You might want to look into hiding it with Javascript or JQuery.

    Also, look at blank cursor files here.

    And one last link to an ajax solution.

    Chrome has had this issue since it was built, there have been reports sent to the people at Chromium, and I assume they are working on it.

    Also, don't trust that anything would work in IE. Ever. :P

    0 讨论(0)
提交回复
热议问题