使用 CSS 禁用链接但启用标题 [英] Disable Link Using CSS but Enable Title

查看:31
本文介绍了使用 CSS 禁用链接但启用标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 CSS 启用链接,但仍然启用标题.这是我的代码:

I want to enable link using CSS but still enable title. Here is my code:

CSS 和 HTML 代码:

.disabledLink {
   pointer-events: none;
   opacity: 0.6;
   cursor: default;
 }

<a href="www.google.com" class="disableLink" title="My Title" /> 
  <span datahover="test">My Link</span> 
</a>

不幸的是,将鼠标悬停在链接上时没有出现标题.有没有更好的方法来启用标题?

Unfortunately, title is not appearing when hovering my mouse to the link. Is there a better way to enable title?

推荐答案

.disabled-link {
  pointer-events: none;
}

<span datahover="test" title="My Title"><a href="www.google.com" class="disabled-link">My Link</a></span>

将您的标记更改为此.它会起作用.我没有针对 <a> 标签,而是针对标题的跨度.希望有帮助.

Change your markup into this. It will work. Instead of targeting <a> tag, I target the span for title. Hope it helps.

这篇关于使用 CSS 禁用链接但启用标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆