更新时间:2023-01-20 11:37:54
你不能这样做...
通过css URL
你放在 background-image
只是为图像。
via css the URL
you put on the background-image
is just for the image.
Via HTML
您必须以此方式为您的超链接添加 href
:
Via HTML
you have to add the href
for your hyperlink in this way:
<a href="http://home.com" id="logo">Your logo</a>
使用 text-indent
code> css ,您可以调整您的元素,只显示图片并点击它,您将转到您的链接。
With text-indent
and some other css
you can adjust your a element to show just the image and clicking on it you will go to your link.
编辑:
因为我相信你是懒惰的搜索什么文本缩进做和尝试我的代码图片上的文字我在这里再次向您展示并解释为什么我的解决方案更好:
Because I'm sure you're lazy to search what text-indent do and trying my code you had text on your image I'm here again to show you and explain why my solution is much better:
<a href="http://home.com" id="logo">Your logo name</a>
HTML
SEO友好,因为您的链接中有一些文本。
This block of HTML
is SEO friendly because you have some text inside your link!
如何使用css风格:
#logo {
background-image: url(images/logo.png);
display: block;
margin: 0 auto;
text-indent: -9999px;
width: 981px;
height: 180px;
}
那么如果你不在乎 SEO 好选择其他答案。
Then if you don't care about SEO good to choose the other answer.