gpt4 book ai didi

html - CSS 中基于图像的菜单

转载 作者:行者123 更新时间:2023-11-28 08:50:12 25 4
gpt4 key购买 nike

我正在尝试在此处遵循本教程: http://inobscuro.com/tutorials/image-rollover-menu-19/

但我只得到没有图像的元素符号列表。

我已确认我的 CSS 文件已包含在内,因为我可以更改整个页面的背景颜色。

我已经验证我可以使用标签在我的主页上包含图像,URL 如下所示:“img/nav/nav_news.png”这些是我用于菜单的相同 URL。

我已经尝试将样式表的 url() 部分中的 url 括在引号中,不带引号。

我也试过在 CSS 文件中扩展菜单的宽度和高度,猜测宽度和高度对于我的图像(140x50 像素)来说可能太小了,但也没有成功。

知道为什么这可能行不通吗?我的 index.html:

<!DOCTYPE html 
PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html lang="en-US">
<head profile="http://www.w3.org/2005/10/profile">

<link rel="icon"
type="image/png"
href="favicon.png">

<link rel="shortcut icon"
type="image/png"
href="favicon.png">

<link rel="stylesheet"
type="text/css"
href="all.css">

<title>Test</title>

</head>

<body>
<ul class="menu">
<li class="news"><a href="#">News</a></li>
<li class="merch"><a href="#">Merch</a></li>
<li class="shows"><a href="#">Shows</a></li>
<li class="contact"><a href="#">Contact</a></li>
</ul>
</body>

</html>

还有我的 all.css:

.menu {
margin: 0;
padding: 0;
width: 200px;
list-style: none;
background: #fff;
}

.menu li {
padding: 0;
margin: 0;
height: 70px;
list-style: none;
background-repeat: no-repeat;
}

.menu li a, .menu li a:visited {
display: block;
text-decoration: none;
text-indent: -9999px;
height: 70px;
background-repeat: no-repeat;
}

.news {background-image: url("img/nav/nav_news.png");}
.news a {background-image: url("img/nav/nav_news.png");}
.merch {background-image: url("img/nav/nav_merch.png");}
.merch a {background-image: url("img/nav/nav_merch.png");}
.shows {background-image: url("img/nav/nav_shows.png");}
.shows a {background-image: url("img/nav/nav_shows.png");}
.contact {background-image: url("img/nav/nav_contact.png");}
.contact a {background-image: url("img/nav/nav_contact.png");}

ul.menu li a:hover {background: none;}

非常感谢!

最佳答案

从您的代码中删除此样式:text-indent: -9999px;并再次验证图片路径。

关于html - CSS 中基于图像的菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27394182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com