我想获得一个图像来显示我的导航栏的背景,我已经看了几个代码示例和示例在这个网站和其他地方,但是,我有运气修复我的错误。如何获取要在导航栏中显示的图像?
这是标记:
<!--DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="icon" type="img/png" href="Johns Cars Shadow.ico" />
<link href="styles.css" rel="stylesheet" type="text/css">
<title>Johns Cars</title>
<style type="text/css">
#main {
box-shadow: 0px 10px 10px 15px #888888;
}
</style>
</head>
<body bgcolor="#ffffff" marginwidth="95" link="#FFFFFF">
<table id="main" bgcolor="#ffffff" width="1200" align="center">
<tr>
<td>
<div id="container" align="center" width="1200">
<div id="logo">
<table align="center" width="345" height="167">
<tr>
<td>
<div>
<img src="Johns cars Shadow.png" width="341" height="167"/>
</div>
</td>
</tr>
</table>
</div>
<div id="navbar">
<ul class="cssmenu">
<li id="active"><a href="home.html"><span>Home</span></a></li>
<li><a href="#"><span>Products</span></a></li>
<li><a href="#"><span>About</span></a></li>
<li id="last"><a href="#"><span>Contact</span></a></li>
</ul>
</div>
</div>
</td>
</tr>
</table>
</body>
</html>
这是CSS:
ul.cssmenu {
margin: 0;
padding: 0;
list-style-type: none;
width: auto;
position: relative;
display: block;
height: 30px;
font-size: 12px;
font-weight: bold;
background-image: transparent url(../images/nav.png) repeat-x top left;
font-family: Arial, Helvetica, sans-serif;
border-bottom: 1px solid #000000;
border-top: 1px solid #000000;
}
ul.cssmenu li {
display: block;
float: left;
margin: 0;
padding: 0;
}
ul.cssmenu li a {
display: block;
float: left;
color: #999999;
text-decoration: none;
font-weight: bold;
padding: 8px 20px 0 20px;
}
ul.cssmenu li a:hover {
color: #4d4d4d;
height: 22px;
background-image: transparent url(../images/nav.png) 0px -30px no-repeat;
}
ul.cssmenu li:active a {
display: inline;
height: 22px;
background-image: transparent url(../images/nav.png) 0px -30px no-repeat;
float: left;
margin: 0;
}
任何帮助将受到欢迎!
为什么你的DTD包裹在''? – Dai
对于一个将'../ images/nav.png'更改为'images/nav.png'。 '../'意味着从样式表所在的父目录。看看你的源代码,你的style.css文件位于你的根目录下,所以我猜你的'images'文件夹也在根目录下。 此外,您要使用'background'而不是'background-image',因为您指定的不仅仅是图片url。 另外,请勿使用表格来布置页面。并且不要使用标签属性来设置颜色,边距,宽度和文本对齐。这是CSS的用途。 – 3dgoo
创建一个小提琴.. – Sasidharan