内部链接
我正在尝试破解非常简单的坚果。我仅使用 CSS 进行图像翻转。当我插入 a href 链接时,它不起作用。我所说的“不起作用”是指它不像一个链接,因此您无法点击进入该页面。认为它与
有关,但我不知道是什么。这是我的 HTML 和 CSS:CSS
ul.navigation,
ul.navigation ul {
margin: 25px 0 0 0;
}
ul.navigation li {
list-style-type: none;
margin:15px;
}
.AboutUsNav{
display: block;
width: 159px;
height: 54px;
background: url('../images/N_About_Us.png') bottom;
text-indent: -99999px;
}
.AboutUsNav:hover {
background-position: 0 0;
}
HTML
<div>
<ul class="navigation">
<li class="AboutUsNav"><a href="/about">About Phin & Phebes Ice Cream</a></li>
<li class="FlavorsNav"><a href="/flavors">Ice Cream Flavors</a></li>
<li class="WheretoBuyNav"><a href="/buy">Where to Buy Our Ice Cream</a></li>
<li class="WholesaleNav"><a href="/wholesale">Wholesale Orders Ice Cream</a></li>
<li class="ContactUsNav"><a href="/contact">Contact Phin & Phebes Ice Cream</a></li>
<li><a href="http://phinandphebes.com/about">about</a></li>
</ul>
</div>
Pretty simple nut I'm trying to crack. I'm doing image rollovers with CSS only. When I plugged in my a href link, it just does not work. By not work I mean, it does not act like it's a link and as a result you cannon click through to the page. Figuring it has something to do with the <li>
but I can't figure out what. Here's my HTML and CSS:
CSS
ul.navigation,
ul.navigation ul {
margin: 25px 0 0 0;
}
ul.navigation li {
list-style-type: none;
margin:15px;
}
.AboutUsNav{
display: block;
width: 159px;
height: 54px;
background: url('../images/N_About_Us.png') bottom;
text-indent: -99999px;
}
.AboutUsNav:hover {
background-position: 0 0;
}
HTML
<div>
<ul class="navigation">
<li class="AboutUsNav"><a href="/about">About Phin & Phebes Ice Cream</a></li>
<li class="FlavorsNav"><a href="/flavors">Ice Cream Flavors</a></li>
<li class="WheretoBuyNav"><a href="/buy">Where to Buy Our Ice Cream</a></li>
<li class="WholesaleNav"><a href="/wholesale">Wholesale Orders Ice Cream</a></li>
<li class="ContactUsNav"><a href="/contact">Contact Phin & Phebes Ice Cream</a></li>
<li><a href="http://phinandphebes.com/about">about</a></li>
</ul>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的
.AboutUsNav
具有text-indent: -99999px;
,将a
拉到可点击视口之外。您可能希望将负的
text-indent
放在a
本身上,然后将a
元素设置为display: block;宽度:100%; height: 100%
,根据您的情况而定。Your
.AboutUsNav
hastext-indent: -99999px;
, pulling thea
outside of the clickable viewport.You probably want to put the negative
text-indent
on thea
itself, and then set thea
element todisplay: block; width: 100%; height: 100%
, depending on your circumstances.不要将文本缩进和背景应用于列表 - 而是将其应用于链接。
示例:
CSS:
don't apply the text-indent and background to the list - do it to the link instead.
Example:
CSS:
感谢您的帮助。我尝试了你们推荐的方法。我认为这在某些情况下绝对有效。对我来说,我的背景图像没有显示,但链接有效。
我最终通过保持 CSS 不变但更改 HTML 标记来解决这个问题,如下所示:
我正在制作这个演示,其中不包含无序列表: http: //kyleschaeffer.com/best-practices/pure-css-image-hover/
thank you for your help. I tried the approach you both recommended. I think this definitely works under certain circumstances. For me, my background image just wasn't showing up but the links were working.
I ended up solving this problem by leaving the CSS the same but changing the HTML markup as so:
I was working off this demo, which didn't include an unordered list: http://kyleschaeffer.com/best-practices/pure-css-image-hover/