【问题标题】:css: how to disable the ability of clicking a link [duplicate]css:如何禁用单击链接的能力[重复]
【发布时间】:2016-01-29 13:59:06
【问题描述】:

我需要通过 css 禁用链接,如果链接可见并且拥有有效的 'href' 属性值,可以这样做吗?

html:

<a class="theLink" href="https://ebay.com">link</a>

css:

.theLink{...?}

【问题讨论】:

  • 提问前请先搜索一下,有一个已经存在的答案,通过简单的搜索即可轻松找到。

标签: html css


【解决方案1】:

是的,您可以禁用它!

html:

<a class="theLinkDisabled" href="https://google.com">link</a>
<br>
<a class="theLinkActive" href="https://google.com">link</a>

css:

.theLinkDisabled{
    pointer-events: none;
    cursor:default;
}

.theLinkActive{
    pointer-events: auto;
    cursor:pointer;
}

【讨论】:

  • 谢谢,我还需要知道如何重新激活它们,完美运行
【解决方案2】:
.thisLink{
   pointer-events: none;
   cursor: default;
}

这是example

【讨论】:

    猜你喜欢
    • 2015-12-23
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    • 2021-12-28
    • 2013-06-02
    • 1970-01-01
    • 2018-12-19
    • 2016-08-03
    相关资源
    最近更新 更多