2014-07-19 254 views
0

我已經創建了這段代碼,但「主頁」似乎不能像鏈接一樣工作。在css a:鏈接中,「文字修飾」似乎可行,但「顏色」不起作用。它不像鏈接那樣響應。下面是代碼:head標籤裏面的div裏面的鏈接不起作用

<!DOCTYPE html> 
<html> 
<head> 

<style> 

h4{ 
float:left; 
margin:10px; 
text-color:white; 
font-family:cursive; 
} 
.exp{ 
margin-left:50px; 
} 
a:link{ 
text-decoration:none; 
color:pink; 
} 
</style> 

</head> 

<body style="background-color:#787878"> 

<div style="background-color:#A2CD5A; 
position:absolute; margin-left:180px; 
margin-top:100px;width:1000px; 
height:750px;"> 
       <div style="background-color:#CAE1FF; 
       position:relative; top:50px;left:250px; 
       width:200px;height:400px;"> 
       </div> 
</div> 

<div style="position:fixed;top:0px;left:0px; 
height:3em;width:100%;background-color:#104E8B; 
z-index:10"> 
    <h4 class="exp"><a href="index.html">Home Page</a></h4> 
    <h4>My Blog </h4> 
    <h4>Accomplishments</h4> 
    <h4>Institutes</h4> 
    <h4>Some Fun!</h4> 
    <h4>Contact Me</h4> 
    <h4>Search:</h4> 
    <h6 style="position:relative;top:-16px"> 
      <form> 
      <input type="text" name="search" value="SearchBox"/> 
     </form> 
     </h6> 
</div> 


</body> 
</html> 
+0

一旦我刪除''邊緣''h4',它適用於我在Firefox中。不過,我無法告訴你爲什麼或者如何解決這個問題。 – ljacqu

回答

3

你的最後一個div,其中包含你的頭,有一個固定的位置和z索引比頁面,這意味着它的身體對你a標籤的頂部。因此,該div下面的任何內容都是無法點擊的。

0

有幾件事情:

  • 儘量尊重div標籤順序。首先是標題,然後內容,等等
  • 您浮動div標籤每次,該分區必須的容器具有屬性「溢出:隱藏」在風格

  • 如果您正在使用一個外部的CSS文件,它不是必須在每個div中添加CSS,你可以用一個ID來做到這一點,因爲你可以在例子中看到

  • 如果你正在使用一個菜單,你必須使用一個列表,它們是不是滴答聲,所以使用標籤h1 ... h6沒有意義。

  • 我不能重寫所有的代碼,但它必須是這樣的(帶有標誌的菜單)。

這是代碼!希望它有幫助 https://drive.google.com/file/d/0B7ID1nfpPSnXRS1KWmhKMnl2RmM/edit?usp=sharing