Html 为什么悬停时手形光标不显示在锚点标签中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16944646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why is the hand cursor not showing in anchor tag when hovered?
提问by kastulo
I have this markup, a label wrapped in an anchor tag, but the problem is the cursor when you hover this doesn't change to the hand cursor,
我有这个标记,一个包裹在锚标签中的标签,但问题是当你悬停时光标不会变成手形光标,
<a href="#17">
<label class="autor">
<span class="by">
by
</span>
Erwin Lutzer
</label>
</a>
what am i doing wrong here?
我在这里做错了什么?
can anyone plz help, thanks!!
谁能帮帮忙,谢谢!!
回答by Derek Henderson
The label is cancelling out the pointer, so make sure your CSS has cursor: pointer;
for both the a and the label:
标签取消了指针,因此请确保您的 CSS 具有cursor: pointer;
a 和标签:
a,
a label {
cursor: pointer;
}
Or better yet, remove the label! It's not valid to have a label inside an anchor.
或者更好的是,删除标签!在锚点内放置标签是无效的。
回答by yurin
Not the answer for actual question, but solution to my own, similar problem:
不是实际问题的答案,而是我自己的类似问题的解决方案:
hand cursor is not showing when hover link.The problem was in the lack of hrefattribute.
悬停链接时不显示手形光标。问题在于缺少href属性。
<a>Link</a> <!-- regular cursor -->
but
但
<a href="#">Link</a> <!-- cursor pointer -->
回答by Denys Séguret
There's no reason to put a label
element in a a
element. The label
element is here to decorate an input. There's no way for this label
to be semantically correct inside a link. As you didn't specify a for
attribute linking to an input, there is no reason for it to show the behavior of an activable element.
没有理由将label
元素放入a
元素中。该label
元素在这里装点的输入。没有办法label
在链接中在语义上是正确的。由于您没有指定for
链接到输入的属性,因此它没有理由显示可激活元素的行为。
Don't use CSS here to add a cursor, this would be semantically incorrect. Replace your label with a span
.
不要在这里使用 CSS 来添加光标,这在语义上是不正确的。将您的标签替换为span
.
回答by C Travel
Use this piece of css on your label
:
在您的label
:
Css code:
css代码:
label.autor{
cursor:pointer;
}
回答by Daniel
As stated by others, it is not valid to put a label inside an anchor tag, but if you really want to do it add the following css code to solve your problem:
正如其他人所说,将标签放在锚标签中是无效的,但如果您真的想这样做,请添加以下 css 代码来解决您的问题:
a label { cursor: pointer; }
Normally you use a label to point to a specific input field so when you click on the label the input field gets focused. Since you don't reference to an input field the label isn't really useful within the anchor tag.
通常,您使用标签指向特定的输入字段,因此当您单击标签时,输入字段将获得焦点。由于您没有引用输入字段,因此标签在锚标记中并没有真正有用。
回答by kslstn
After updating my MacBook to High Sierra 10.13.6 I had to restart to get pointer cursors in any browser back to work.
将我的 MacBook 更新到 High Sierra 10.13.6 后,我必须重新启动才能使任何浏览器中的指针光标恢复工作。