How to disable a link using only CSS?

前端 未结 22 3220
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 02:58

Is there any way to disable a link using CSS?

I have a class called current-page and want links with this class to be disabled so that no action occurs

22条回答
  •  一向
    一向 (楼主)
    2020-11-22 03:44

    The answer is already in the comments of the question. For more visibility, I am copying this solution here:

    .not-active {
      pointer-events: none;
      cursor: default;
      text-decoration: none;
      color: black;
    }
    Link

    For browser support, please see https://caniuse.com/#feat=pointer-events. If you need to support IE there is a workaround; see this answer.

    Warning: The use of pointer-events in CSS for non-SVG elements is experimental. The feature used to be part of the CSS3 UI draft specification but, due to many open issues, has been postponed to CSS4.

提交回复
热议问题