Add CSS cursor property when using “pointer-events: none”

后端 未结 7 1550
时光取名叫无心
时光取名叫无心 2020-11-30 06:52

I\'m trying to disable a specific link and apply cursor style but this CSS command cursor: text; won\'t effect. The cursor is always default. I\'m using latest

7条回答
  •  一生所求
    2020-11-30 07:33

    My use case was a draggable element that couldn't have any pointer-event nor any parent element with a pointer-event.

    I solved it by conditionally applying a global style forcing a grabbing cursor only while dragging. (I'm using React and styled-components, but the same logic can be applied on vanilla js).

    const SetDraggingCursor = createGlobalStyle`
      * {
        cursor: grabbing !important;
      }
    `;
    
    // ...
    
    {isDragging && }
    

提交回复
热议问题