禁用锚标记并在鼠标悬停时显示title-msg为什么禁用它

问题描述 投票:0回答:1

我想禁用Anchor标签并在鼠标悬停时显示标题,为什么它被禁用?

<a href="domain.xyz" title="why it's disabled">sample domain</a>

试过以下:

.disabled {
    opacity: 0.5;
    cursor: default !important;
    pointer-events: none !important;
}

但鼠标悬停不起作用。

有没有指针如何使用CSS?

html css css3
1个回答
0
投票

您可以使用:after显示content: attr(title)元素以显示原因。

a.disabled {
  cursor: not-allowed;
  text-decoration: none;
}

a.disabled:hover::after {
 content: attr(title);
 padding-left: 10px;
 color: black;
}
<a href="#" class="disabled" title="Unavailable now" onclick="return false">Click here</a>
© www.soinside.com 2019 - 2024. All rights reserved.