1

我正在尝试将 CSS 精灵用于导航栏。经过大量的互联网研究,我想我已经确定了“最简单”的方法。除了单击浏览器的“后退”按钮外,一切似乎都可以正常工作。在 IE (8.0.6001.18701) 中,活动状态为“卡住”(看起来按钮被按下)。在 Firefox (14.0.1) 中,悬停状态为“卡住”。我可以忍受 Firefox 的问题,因为一旦鼠标从后退按钮移开,它就会消失,而不是 IE 的问题。我目前在头文件中有导航栏,我将其与 Includes 一起使用以保持简单和一致。这是模板html。我将它用于我的所有页面。(当我解决了这个问题时,我将实际进入其余的身体)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="DS.css">
</head>
<body>
<div id="centerpage">
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="table1">
<tr>
<td>
<!--webbot bot="Include" U-Include="Nav_Includes/Header.htm" TAG="BODY" --></td>
</tr>
<tr>
<td>Enter page data here.<br>
<hr width="770" size="1">
<span id="timestamp">Page last updated: 
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%m/%d/%Y %I:%M %p" --></span></td>
</tr>
<tr>
<td>
<!--webbot bot="Include" U-Include="Nav_Includes/Footer.htm" TAG="BODY" --></td>
</tr>
</table>
</div>
</body>
</html>

这是header.htm:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Dolphin Storage Header</title>
<link rel="stylesheet" type="text/css" href="../DS.css">
</head>
<body>
<img border="0" src="../images/header.jpg" width="760" height="101" align="center">
<p><a class="navHome" href="../index.htm"></a>
<a class="navUnits" href="../units.htm"></a>
<a class="navSpecials" href="../specials.htm"></a>
<a class="navAbout" href="../about.htm"></a>
<a class="navContact" href="../contact.htm"></a></p>
</body>
</html>

该css文件:

body {
font-family: Arial, Helvetica, Sans-serif;
color: #000000;
text-align:center; /* Fix for IE not centering webpage */
background-color: #ffe670;
}
#centerpage {
width: 770px; 
margin: 0 auto;   /* Top & Bottom = 0, Right & Left = auto to center the page horizontally */
text-align:left;  /* 2nd part of IE fix for centering webpage */
}
/* Navagation bar, using 'sprite' images */ 
a.navHome {
display: block;
float: left;
width: 160px;
height: 30px;
background-image: url('Nav_Buttons/Home.jpg');
background-repeat: no-repeat;
background-position; 0 0;
}
a.navHome:hover {
background-position: 0 -30px;
}
a.navHome:active {
background-position: 0 -60px;
}

a.navUnits {
display: block;
float: left;
width: 150px;
height: 30px;
background-image: url('Nav_Buttons/Units.jpg');
background-repeat: no-repeat;
background-position; 0 0;
}
a.navUnits:hover {
background-position: 0 -30px;
}
a.navUnits:active {
background-position: 0 -60px;
}

a.navSpecials {
display: block;
float: left;
width: 150px;
height: 30px;
background-image: url('Nav_Buttons/Specials.jpg');
background-repeat: no-repeat;
background-position; 0 0;
}
a.navSpecials:hover {
background-position: 0 -30px;
}
a.navSpecials:active {
background-position: 0 -60px;
}

a.navAbout {
display: block;
float: left;
width: 150px;
height: 30px;
background-image: url('Nav_Buttons/About.jpg');
background-repeat: no-repeat;
background-position; 0 0;
}
a.navAbout:hover {
background-position: 0 -30px;
}
a.navAbout:active {
background-position: 0 -60px;
}

a.navContact {
display: block;
float: left;
width: 160px;
height: 30px;
background-image: url('Nav_Buttons/Contact.jpg');
background-repeat: no-repeat;
background-position; 0 0;
}
a.navContact:hover {
background-position: 0 -30px;
}
a.navContact:active {
background-position: 0 -60px;
}

#timestamp {
font-family: Arial, Helvetica, Sans-serif;
color: #000000;
font-size: xx-small;
}

H5 {
font-family: Georgia, "Times New Roman", Times, serif;
color: #035f8e;
}

Sprites:(不会让新用户发布图片,抱歉)

4

1 回答 1

0

在使用lvha 原则定义个体和状态之前,使用:link和伪类来设置所有常见的默认状态::visited:hover:active

a.navUnits:link, a.navUnits:visited, a.navSpecials:link, a.navSpecials:visited, a.navAbout:link, a.navAbout:active, a.navContact:link, a.navContact:visited, a.navHome:link, a.navHome:visited { background-position: 0 0; }
于 2012-08-30T05:30:01.473 回答