How to disable a link using only CSS?

前端 未结 22 2914
爱一瞬间的悲伤
爱一瞬间的悲伤 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:21

    The pointer-events property allows for control over how HTML elements respond to mouse/touch events – including CSS hover/active states, click/tap events in Javascript, and whether or not the cursor is visible.

    That's not the only way you disable a Link, but a good CSS way which work in IE10+ and all new browsers:

    .current-page {
      pointer-events: none;
      color: grey;
    }
    This link is disabled

提交回复
热议问题