为什么在悬停链接时不用手()?

发布于 2024-10-18 06:12:54 字数 1331 浏览 2 评论 0原文

嗨,

我知道当悬停像这样的对象时可以将光标设置为手:

CSS :

cursor:             hand;
cursor:             pointer;

这应该使用如下所示的链接元素自动完成:

<a onclick="" class="btn1">
  <span>Sök</span>
</a>

但在我的情况下不是吗?

使用 firebug,我可以看到应用了以下 CSS

<a> element
a.btn1 {
    background: url("Images/Menus/bg_button_a.gif") no-repeat scroll right top transparent;
    color: #444444;
    display: block;
    float: left;
    font: 12px arial,sans-serif;
    height: 24px;
    margin-right: 6px;
    padding-right: 18px;
    text-decoration: none;
}
* {
    margin: 0;
    padding: 0;
}
body {
    font-family: Arial,Verdana,serif;
    font-size: 0.81em;
}

SPAN element
    a.btn1 span {
        background: url("Images/Menus/bg_button_span.gif") no-repeat scroll 0 0 transparent;
        display: block;
        line-height: 14px;
        padding: 5px 0 5px 18px;
    }
    Controls.css (rad 80)
    * {
        margin: 0;
    }

    a.btn1 {
        color: #444444;
        font: 12px arial,sans-serif;
        text-decoration: none;
    }

    body {
        font-family: Arial,Verdana,serif;
        font-size: 0.81em;
    }

我怎样才能找到这个问题?

致以诚挚的问候

Hi,

I know that its possible to set the cusor to hand when hovering an object like this:

CSS :

cursor:             hand;
cursor:             pointer;

This should be done automaticly with a link element that looks like this :

<a onclick="" class="btn1">
  <span>Sök</span>
</a>

But In my case its not?

With firebug I can see that the followin CSS is applyed

<a> element
a.btn1 {
    background: url("Images/Menus/bg_button_a.gif") no-repeat scroll right top transparent;
    color: #444444;
    display: block;
    float: left;
    font: 12px arial,sans-serif;
    height: 24px;
    margin-right: 6px;
    padding-right: 18px;
    text-decoration: none;
}
* {
    margin: 0;
    padding: 0;
}
body {
    font-family: Arial,Verdana,serif;
    font-size: 0.81em;
}

And

SPAN element
    a.btn1 span {
        background: url("Images/Menus/bg_button_span.gif") no-repeat scroll 0 0 transparent;
        display: block;
        line-height: 14px;
        padding: 5px 0 5px 18px;
    }
    Controls.css (rad 80)
    * {
        margin: 0;
    }

    a.btn1 {
        color: #444444;
        font: 12px arial,sans-serif;
        text-decoration: none;
    }

    body {
        font-family: Arial,Verdana,serif;
        font-size: 0.81em;
    }

How can I track down this problem?

BestRegards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

仲春光 2024-10-25 06:12:55

如果没有 href 属性,a 标记不会声明超链接。如果它拥有 nameid 属性,则它可以声明超链接的目的地。 (http://www .w3.org/TR/html4/struct/links.html#anchors-with-id)

如果您要声明的元素与超链接没有语义相似性,并且您依靠 CSS 使其看起来像一、何苦呢?您也可以使用任何旧的 span

你不应该做的是写一个{cursor:pointer; } 到您的 CSS 中,导致任何 a 元素在悬停时显示手形,即使是那些不是超链接的元素。相反,您应该像建议的那样添加 href 属性。如果没有可供依赖的非 JavaScript 功能,您可以输入 # 作为值。否则,您应该输入要链接到的资源的 URI。

另请参阅维基百科:http://en.wikipedia.org/wiki/HTML_element#Anchor

Without the href attribute the a tag does not declare a hyperlink. If it possesses a name or id attribute, it may declare the destination of a hyperlink instead. (http://www.w3.org/TR/html4/struct/links.html#anchors-with-id)

If the element you want to declare has no semantic resemblance to a hyperlink and you are relying on CSS to make it appear like one, why bother? You might just as well use any old span.

What you should not do is write a { cursor:pointer; } into your CSS, causing any a elements to display a hand on hover, even those that are not hyperlinks. Instead you should add a href attribute like has been suggested. As a value you could enter # if there is no non-JavaScript functionality to fall back on. Otherwise you should enter the URI of the resource you want to link to.

See also Wikipedia: http://en.wikipedia.org/wiki/HTML_element#Anchor

爱情眠于流年 2024-10-25 06:12:55

那不是链接。链接具有 href 属性。这只是一个在单击时运行 JavaScript 的锚点。

That's not a link. Links have href attributes. That's just an anchor that runs JavaScript when clicked.

人│生佛魔见 2024-10-25 06:12:54

仅当 ANCHOR 设置了 href 属性时,手才会出现。

现场演示: http://jsfiddle.net/KAEbR/

The hand appears only if the ANCHOR has a href attribute set.

Live demo: http://jsfiddle.net/KAEbR/

最冷一天 2024-10-25 06:12:54

这可能是因为您没有“href”值,您可以将其更改为

<a href="#" onclick="" class="btn1"/>

您还可以添加以下 css 以强制手始终显示链接:

a{ cursor: pointer;}

It's likely because your doesn't have a "href" value, you could change it to

<a href="#" onclick="" class="btn1"/>

You can also add the following css to force the hand to always appear for links:

a{ cursor: pointer;}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文