Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

html - 如何仅使用CSS禁用链接?(How to disable a link using only CSS?)

Is there any way to disable a link using CSS?

(有没有办法使用CSS禁用链接?)

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

(我有一个名为current-page的类,并希望禁用此类的链接,以便在单击它们时不会发生任何操作。)

  ask by RSK translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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; } 
 <a href="link.html" class="not-active">Link</a> 

For browser support, please see https://caniuse.com/#feat=pointer-events .

(有关浏览器支持,请参阅https://caniuse.com/#feat=pointer-events 。)

If you need to support IE there is a workaround;

(如果你需要支持IE,有一个解决方法;)

see this answer .

(看到这个答案 。)

Warning: The use of pointer-events in CSS for non-SVG elements is experimental.

(警告:在CSS中为非SVG元素使用pointer-events是实验性的。)

The feature used to be part of the CSS3 UI draft specification but, due to many open issues, has been postponed to CSS4.

(该功能曾经是CSS3 UI草案规范的一部分,但由于许多未解决的问题,已被推迟到CSS4。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...