html - 超链接的异常行为

时间:2013-06-18 16:01:20

标签: html css hyperlink

我创建了一个div,其中我放了一些超链接。在那些,我添加了一些样式,当我将鼠标悬停在它们上面时,它们会显示下划线,非常简单。但当我试图将鼠标悬停在它们上面时,会出现一条不寻常的小线。

这是jsFiddle

HTML:

<section id="header">
    <div id="header-links-holder">  
        <a href="#"><span>HOME</span>
        <a href="#"><span class="no-spacing">ABOUT US</span></a>
        <a href="#"><span>PORTFOLIO</span></a>
        <a href="#"><span class="no-spacing">CONTACT US</span></a>
    </div>
</section>

CSS:

html, body{
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

#header {
    width: 100%;
    height: 30%;
    background-image: url(http://www.7daysinhavana.com/wordpress/wp-content/themes/7days/images/commun/back_header_global.jpg);
    font-family: 'GarageGothicBlackRegular';
    word-spacing: 20px;
    font-size: 25px;
    text-align: center;
    position: relative;
}

#header-links-holder {
    position: absolute;
    width:100%;
    bottom: 0px;
}

#header a {
    color: black;
    text-decoration: none;
}

#header a:hover{
    text-decoration: underline;
}

.no-spacing {
    word-spacing: 0px;
}

请尝试将鼠标悬停在HOME链接上,然后查看结果。

如何解决此错误?

2 个答案:

答案 0 :(得分:4)

这是一个错字,您没有关闭a代码

<a href="#"><span>HOME</span></a>

Demo

始终使用validator来避免此类错误,并使用firebug

等调试工具
  

注意:据我所知,还查看HTML文档的来源,   Firefox将以红色突出显示杂散标记

答案 1 :(得分:1)

这是你的问题:

<a href="#"><span>HOME</span>

你忘记了结束

    <a href="#"><span>HOME</span></a>