2012-10-17 53 views
0

我正在嘗試實踐圖像替換技術,主要用於導航目的。我似乎無法弄清楚爲什麼它不起作用。懸停工作,但默認的菜單項不。我很確定事情寫得正確。爲什麼這個圖像替換技術不起作用?

http://lrroberts0122.github.com/DWS/practical/index.html

這裏的FO導航的HTML:

<ul id="nav"> 
    <li id="process"><a href="index.html" id="active">Our Process</a></li> 
    <li id="function"><a href="function.html">Bio-Built Function</a></li> 
    <li id="future"><a href="future.html">The Future</a></li> 
    <li id="engage"><a href="engage.html">Engage Dio</a></li> 
</ul> 

這裏是我的導航CSS:

#nav { 
    list-style: none; 
    width: 244px; 
    height: 124px; 
    overflow: hidden; 
    } 

#nav li { 
    float: left; 
    } 

#nav li a { 
    width: 244px; 
    height: 30px; 
    text-indent: 100%; 
    white-space: nowrap; 
    overflow: hidden; 
    display: block; 
    background: url('../img/bg_nav.png'); 
    } 

#process { 
    background-position: 0 0; 
    } 

#process:hover { 
    background-position: -244px 0; 
    } 

#function { 
    background-position: 0 -31px; 
    } 

#function:hover { 
    background-position: -244px -31px; 
    } 

#future { 
    background-position: 0 -60px; 
    } 

#future:hover { 
    background-position: -244px -62px; 
    } 

#engage { 
    background-position: 0 -90px; 
    } 

#engage:hover { 
    background-position: -244px -93px; 
    } 
+1

你的問題不是很清楚......如果是用id =「active」,我沒有看到上面的CSS? – robC

+0

如果您查看html文件,所有鏈接都會顯示「我們的流程」。我試圖重新定位背景,但由於某種原因,它不工作,我不知道爲什麼。 – Lindsay

回答

0

我將包括:

#nav li a { 
    width: 244px; 
    height: 30px; 
    text-indent: 100%; 
    white-space: nowrap; 
    overflow: hidden; 
    display: block; 
    background: url('../img/bg_nav.png'); 
    } 

的#process(其中的方式類可能更好地工作)

#process { 
     width: 244px; 
     height: 30px; 
     text-indent: 100%; 
     white-space: nowrap; 
     overflow: hidden; 
     display: block; 
     background: url('../img/bg_nav.png'); 

擺脫#nav li a 在CSS而不是HTML,並試試這個:

#process { 
     width: 244px; 
     height: 30px; 
     text-indent: 100%; 
     white-space: nowrap; 
     overflow: hidden; 
     display: block; 
     background: url('../img/bg_nav.png'); 
     background-position: 0 0; 
} 

#process:hover { 
    background-position: -244px 0; 
} 

等,爲功能&其他...

,如果我錯過了什麼,或者如果你有任何問題,請在意見。