logo 里面首先放一个 h1 标签,目的是为了提权,告诉搜索引擎,这个地方很重要。
h1 里面再放一个链接,可以返回首页的,把 logo 的背景图片给链接即可。
为了搜索引擎收录我们,我们链接里面要放文字(网站名称),但是文字不要显示出来。
方法1:
text-indent
移到盒子外面(text-indent: -9999px;
) ,然后overflow:hidden;
,淘宝的做法。
方法2:直接给
font-size: 0;
就看不到文字了,京东的做法。
最后给链接一个 title 属性,这样鼠标放到 logo 上就可以看到提示文字了。
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.logo {
position: absolute;
top: 25px;
width: 171px;
height: 61px;
}
.logo a {
display: block;
width: 171px;
height: 61px;
background: url(../images/logo.png) no-repeat;
/* font-size: 0;京东的做法*/
/* 淘宝的做法让文字隐藏 */
text-indent: -9999px;
overflow: hidden;
}
</style>
</head>
<body>
<!-- logo模块 -->
<div class="logo">
<h1>
<a href="index.html" title="网站名">网站名</a>
</h1>
</div>
</body>
</html>
发表评论