How do I make a link unclickable?

前端 未结 11 723
伪装坚强ぢ
伪装坚强ぢ 2020-12-08 19:37

Is there some CSS property or something that I can use with my anchor tag so as to make it unclickable or I HAVE to do stuff in code behind to get what I want?

11条回答
  •  感动是毒
    2020-12-08 20:21

    The pointer-events CSS property can be set in modern browsers on a particular graphic element and tells under what circumstances the element can become the target of pointer events.

    The none value makes sure that the element is never the target of pointer events and prevents all click, state and cursor options on the element.

    a {
      display: inline-block;
      pointer-events: none;
    }
    
      
        
      
    

    However, pointer events may target its descendant elements if those descendants have pointer-events set to some other value. In these circumstances, pointer events will trigger event listeners on this parent element as appropriate on their way to/from the descendant during the event capture/bubble phases. - MDN

    a {
      display: inline-block;
      pointer-events: none;
    }
    a svg {
        pointer-events: fill;
    }
    
      
        
      
    

提交回复
热议问题