2012-07-25 65 views
1

我想爲導航欄使用CSS精靈。經過大量的互聯網調查,我認爲我已經確定了「最簡單」的方式。所有似乎都正常工作,除非我點擊瀏覽器的後退按鈕。在IE(8.0.6001.18701)中,活動狀態「卡住」(看起來像按下按鈕)。在Firefox(14.0.1)中,懸停狀態「卡住」。只要鼠標移出後退按鈕,我就可以忍受Firefox問題,但不會出現IE問題。我目前在包含的頭文件中使用了navbar,以保持簡單和一致。 這是Template html。我用我的所有網頁。 (當我拿過去這個問題,我將在實際工作中的屍體的其餘部分進入)css精靈仍然在瀏覽器上顯示活動狀態返回按鈕

<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 :(不會讓新用戶發佈圖片,對不起)

+0

請注意,不正確的分號「;」在一些背景位置被修正爲冒號「:」後,但沒有解決問題。 – user1549510 2012-07-26 13:30:16

回答

0

使用:link:visited僞類設置所有常見的默認狀態使用lvha principle定義個人: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; } 
+1

問題解決了。謝謝! – user1549510 2012-10-01 16:05:30

相關問題