2013-02-21 71 views
1

當我嘗試鏈接到標題頂部時無法正常工作。我的事情這是Div z-index的錯誤。但我無法得到它。任何人都可以幫我解決這個問題。我附上了與此相關的內容。請使用以下鏈接查看網站。鏈接在標題中不起作用

http://10.8.12.41/srilanka/ 


    #header{ 


    color: #CFCFCF; 
    font-weight: 600; 
    /*border-bottom: 4px solid #84AE03;*/ 
    background:#fff; 
    width: 100%; 
    z-index: 10; 

     } 
    #banner{ 
      height: 100%; 
    margin: 0px auto 0; 
    position: relative; 
    width: 1000px; 
    z-index: 1;} 
    #topnavbar{ 
     height: 26px; 
    /* margin:-5px 102px 0 0;*/ 

    position: relative; 
    background:url(../images/top_lin.png) repeat-x; 
    float:left; 
    width:100%; 
    float:right; 

    } 
    #topnavmenu{ 
     float:right; 
     width:300px; 
     padding:3px; 
    } 
    #topnavmenu a{ 
     color: #FFFFFF; 
    display: inline-block; 
    font-family: 'Open Sans Condensed',sans-serif; 
    font-size: 11px; 
    font-weight: 600; 
    /*line-height: 35px;*/ 
    padding: 0; 
    text-align: center; 
    text-decoration: none; 
    width: auto; 
    z-index:10px; 
    } 
#apDiv2 { 
    height: 100%; 
    margin:0px auto; 
    position: relative; 
    width: 1000px; 
    z-index: 1; 
    background:url(../images/menubg.png) repeat; 
    background-color:#00247d; 

} 

Html 
------------------------------------------------ 

<div id="topnavbar"> 
<div id="topnavmenu"> 
<a href="#">CheckmyTrip</a> |<a href="#">Baggage</a> | <a href="#">Travel Tips</a> 
</div> 
</div> 

<div id="banner"> 

<img src="images/Banner.png" /> 

</div> 




<div id="apDiv2"> 
<!-- Start css3menu.com BODY section id=2 --> 
<ul id="css3menu2" class="topmenu"> 


    <li class="toplast"><a href="contactus.php" style="height:32px;line-height:32px;"><img src="index_files/css3menu2/contact.png" alt=""/>Contact Us</a></li> 
</ul> 
<p style="display:none"><a href="http://css3menu.com/">Pure CSS Dropdown Menus Css3Menu.com</a></p> 
<!-- End css3menu.com BODY section --> 

<p style="display:none"><a href="http://css3menu.com/">Pure CSS Dropdown Menus Css3Menu.com</a></p> 
<!-- End css3menu.com BODY section --> 


</div> 
+0

'z-index:10px'無論如何 – 2013-02-21 06:27:36

+0

你能分享你的html代碼嗎???? – 2013-02-21 06:28:28

+0

什麼鏈接?你可以在html中顯示相關的標籤 – lukeocom 2013-02-21 06:28:32

回答

1

z-index on #banner是你的大部分問題。

http://jsfiddle.net/JwPjA/3/

#header { 
    color: #CFCFCF; 
    font-weight: 600; 
    /*border-bottom: 4px solid #84AE03;*/ 
    background:#fff; 
    width: 100%; 
} 
#banner { 
    height: 100%; 
    margin: 0px auto 0; 
    position: relative; 
    width: 1000px; 
    z-index: -1; 
} 
#topnavbar { 
    height: 26px; 
    /* margin:-5px 102px 0 0;*/ 
    position: relative; 
    background:url(http://placehold.it/26x26) repeat-x; 
    width:100%; 
    float:right; 
} 
#topnavmenu { 
    float:right; 
    width:300px; 
    padding:3px; 
} 
#topnavmenu a { 
    color: #FFFFFF; 
    display: inline-block; 
    font-family:'Open Sans Condensed', sans-serif; 
    font-size: 11px; 
    font-weight: 600; 
    /*line-height: 35px;*/ 
    padding: 0; 
    text-align: center; 
    text-decoration: none; 
    width: auto; 
    z-index:10px; 
} 
#apDiv2 { 
    height: 100%; 
    margin:0px auto; 
    position: relative; 
    width: 1000px; 
    z-index: 1; 
    background:url(http://placehold.it/300x300) repeat; 
    background-color:#00247d; 
} 

在不同的音符,我看到你學習,因爲這代碼有許多事情錯。你做得很好,但這裏有幾點。首先,float: leftfloat:right在同一類沒有任何意義。那麼你也是浮動的元素,在一些地方不需要它。 position是一個先進的屬性,影響z-indexz-index不會工作,沒有position它可以並且通常應該至少與其中一個使用:topleftrightbottom。我只會在你認爲你需要的時候使用它。我認爲你的佈局是可以完成的,沒有position

很多網站上的人都不喜歡W3Schools,但他們對於像你這樣的初學者來說非常棒。

保持良好的工作,你會變得更好。