2013-08-25 125 views
0

摘要:我希望我的菜單欄得到修復(我已經實現了這個功能),但是我遇到了一個問題,在滾動過程中,內容會移動到固定菜單而不是在菜單欄下。 我查了不同的網站,我在SO CSS - Make Content Appear Beneath a Fixed DIV Element 上看到一個相關的問題,但它不適用於我,我想知道爲什麼? 這裏是我的html代碼:菜單欄固定時在菜單欄上滾動的元素

 <!-- 
To change this template, choose Tools | Templates 
and open the template in the editor. 
--> 
<!DOCTYPE html> 
<html> 
    <head> 
     <title></title> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <link href="fixed.css" type="text/css" rel="stylesheet"/> 
    </head> 
    <body> 
     <table class="fixed-bar" width="1333" height="48" border="0" align="center"> 
      <tr> 
       <td width="96" rowspan="2">&nbsp;</td> 

       <td><hsso style="font:'Trebuchet MS', Arial, Helvetica, sans-serif; text-shadow:#0C0 0.1em 0.1em 0.3em; color:#030; font-size:32px; text-align:center;"> Fixed Bar.</hsso></td> 
     <td><a class="linear" href="signup"> 
       <span>Sign Up </span> 

      </a> 
     </td> 
    </tr> 
    <tr> 
     <td class="nav-bar1" align="left"> 



     </td> 
     <td width="158" align="left">&nbsp;</td> 
    </tr> 
</table> 
     <div style="height: 80px; width: 100%;"></div> 
<table width="361" height="891" border="0" align="center" class="tab1" > 
    <tr> 
     <td width="467" align="center"><input placeholder="Username" autocomplete="on" class="inp" type="text" name="un" id="un"></td> 
    </tr> 
    <tr> 
     <td align="center"><input placeholder="Password" autocomplete="on" class="inp" type="text" name="pw" id="pw"></td> 
    </tr> 
    <tr> 
     <td align="center"><input placeholder="Re-enter Password" autocomplete="on" class="inp" type="text"></td> 
    </tr> 
    <tr> 
     <td align="center"><input placeholder="First Name" autocomplete="on" class="inp" type="text" name="fn" id="fn"></td> 
    </tr> 
    <tr> 
     <td align="center"><input placeholder="Last Name" autocomplete="on" class="inp" type="text" name="ln" id="ln"></td> 
    </tr> 
    <tr> 
     <td align="center"><select class="sel" name="st" id="st"> 
     <option>Please Select your Set</option> 
     <option>1997/1998</option> 
     <option>1998/1999</option> 
     <optiom>1999/2000</optiom> 
     <option>2001/2002</option> 
     <option>2002/2003</option> 
     <option>2003/2004</option> 
     <option>2005/2006</option> 
     <option>2006/2007</option> 
     <option>2007/2008</option> 
     <option>2008/2009</option> 
     <option>2009/2010</option> 
     <option>2010/2011</option> 
     <option>2011/2012</option> 
     <option>2012/2013</option> 

     </select></td> 
    </tr> 
    <tr> 
     <td align="center"><input placeholder="Email" autocomplete="on" class="inp" type="text" name="em" id="em"></td> 
    </tr> 
    <tr> 
     <td align="center"><input class="reg" type="submit" name="reg" id="reg" value="  Register  "></td> 
    </tr> 

    </table> 
    </body> 
</html> 

和我的CSS:

table.fixed-bar{ 
     box-shadow:#0C0 0.1em 0.2em 0.5em 0.1em; 
    border-radius: 8px; 
    position: fixed; 
    top: 0; 
    width: 100%; 
    left: 0; 
    clear: both; 

} 
table.tab1{ 
    border-radius: 8px; 
    box-shadow:#0C0 0.1em 0.2em 0.5em 0.1em; 

} 

感謝。

回答

2

你應該給.fixed-bar更高z-index

.fixed-bar { z-index: 1000; }

+0

非常感謝。這完美的作品,尤其是對我的項目。 –

1

您沒有分配給固定位置元素的背景。

試着給它一個背景顏色,它不應該是透明的了。

background:#fff; 

SOLUTION:

http://jsfiddle.net/8T2zt/

+0

謝謝,它運作良好。但它不適用於我的真實項目,即使添加了背景屬性。您是否知道爲什麼? –

+0

您的真實項目是否託管?或者它是本地的?它應該工作,除非在更新它們之後不保存文件。 – gespinha

+0

它是本地的,它在添加z-index屬性後立即生效。 –

1

我必須有兩個Z-index屬性,給它一個高值,也可以設置背景屬性。