tab-ver.tab {
background: url(../images/16by16.png) no-repeat center center;
text-indent: -10000em;
height: 16px;
width: 16px;
padding: 4px 1px;
margin-right: 1px;
margin-left: 50px;
}
<div id="tab-ver" class="tab"><a href="http://www.yahoo.com">English</a></div>
以上脚本的问题是,一个链接不会在所有的工作。如果用户点击16by16.png图片,用户不会重定向到yahoo.com。CSS - 如何让一个DIV中的一个连接工作与背景图像
但是要解决这个问题?
谢谢
// update001//
I have tried the following suggestion:
#tab-ver.tab {
text-indent: -10000em;
}
#tab-ver.tab a{
background: url(../images/16by16.png) no-repeat center center;
height: 16px;
width: 16px;
padding: 4px 1px;
margin-right: 1px;
margin-left: 50px;
display: block;
}
它为我原来的问题。但是,显示的图像现在偏移到水平菜单的底部。这是由'display:block'造成的。但是,如果我删除'display:block',那么图像将不可见。
谢谢
// update 1 //
Based on the suggestion, the following script works best for me
#tab-en-ver.tab a {
background: url(../images//16by16.png) no-repeat center center;
height: 16px;
width: 16px;
padding: 4px 1px;
margin-right: 1px;
margin-left: 50px;
text-indent: -10000em;
}
然而,这个建议确实有一个问题。文字“英文”与图像混合。我无法弄清楚如何从链接中删除“英文”文本。
通过添加下面的额外规则将导致图像消失。
#tab-ver.tab {
text-indent: -10000em;
}
有什么想法吗?
你好MainMa,我应该在哪里放这个IMG?谢谢 – q0987 2010-09-08 02:10:46
他们不是'黑客'的任何定义的单词 - 图像替换是一个有效的技术,是跨浏览器兼容和广泛使用 – 2010-09-08 02:15:40
你好MainMa,请检查这个图像http://i52.tinypic.com/245hax1 .png正如你所看到的,当鼠标悬停在图像上时,会出现白色背景。你知道如何解决这个问题吗?谢谢 – q0987 2010-09-08 02:17:07