【问题标题】:Clickable Header Image Missing Text可点击的标题图像缺少文本
【发布时间】:2015-03-18 14:15:53
【问题描述】:

我的网站有一个标题图片,它也是主页的链接。

HTML

<div id="header">
    <a href="~/Default.aspx" runat="server" id="homelink"></a>
</div>

CSS

#header {
position: relative;
height: 150px;
width: 1000px;
margin: 0px auto;
background-image: url("../Styles/Images/Header.jpg"); /*--ZaraA (2014)--*/
background-repeat: no-repeat;
}

#homelink {
position: absolute;
display: inline-block;
width: 1000px;
height: 150px;
top: 0;
left: 0;
float: left;
}

这是一项大学作业,因此我的页面必须尽可能易于访问。上面的可访问性检查失败,因为锚标记内没有文本。

如何在标签内添加一些文本但使其不可见,同时确保整个标题图像仍可点击返回主页。谢谢你

【问题讨论】:

    标签: html image header tags anchor


    【解决方案1】:

    将 tekst 添加到您的锚标记。然后添加以下 CSS:

    #homelink {
        text-indent: -9999px;
        overflow: hidden;
    }
    

    这会将文本“推”出元素的可见部分。 所以它会是:

    #homelink {
        position: absolute;
        display: inline-block;
        width: 1000px;
        height: 150px;
        top: 0;
        left: 0;
        float: left;
        text-indent: -9999px;
        overflow: hidden;
    }
    

    【讨论】:

      猜你喜欢
      • 2013-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-21
      • 2019-07-20
      • 2018-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多