How to disable a link using only CSS?

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

    you can use this css:

    a.button,button {
        display: inline-block;
        padding: 6px 15px;
        margin: 5px;
        line-height: 1.42857143;
        text-align: center;
        white-space: nowrap;
        vertical-align: middle;
        -ms-touch-action: manipulation;
        touch-action: manipulation;
        cursor: pointer;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        background-image: none;
        border: 1px solid rgba(0, 0, 0, 0);
        border-radius: 4px;
        -moz-box-shadow: inset 0 3px 20px 0 #cdcdcd;
        -webkit-box-shadow: inset 0 3px 20px 0 #cdcdcd;
        box-shadow: inset 0 3px 20px 0 #cdcdcd;
    }
    
    a[disabled].button,button[disabled] {
        cursor: not-allowed;
        opacity: 0.4;
        pointer-events: none;
        -webkit-touch-callout: none;
    }
    
    a.button:active:not([disabled]),button:active:not([disabled]) {
        background-color: transparent !important;
        color: #2a2a2a !important;
        outline: 0;
        -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .5);
        box-shadow: inset 0 3px 5px rgba(0, 0, 0, .5);
    }
    
    
    test
    test2

提交回复
热议问题