2015-11-04 96 views
0

我有一個有兩個標記的代碼。第一個不工作,而第二個工作。爲什麼?這裏是我的代碼:<a>標記不起作用

<div id="logo"> 
    <img src="/logo.png" height="150" width="300"> 
</div> 
<div id="home"> 
    <a href="#"> 
     <img src="/home.png" height="95" width="95"> 
     <br> 
     <b>HOME</b> 
    </a> 
</div> 
<div id="news"> 
    <a href="#"> 
     <img src="/news.png" height="95" width="95"> 
     <br><b>NEWS</b> 
    </a> 
</div> 

這是我的頁面的CSS:

  #form{ 
       padding:2px; 
       margin:0 auto; 
       background:rgba(110,110,110,0.1); 
       width:600px; 
position: relative; 
    left: 0px; 
top: -230px; 
      } 
#home { 
position: relative; 
    left: -30px; 
top: -145px; 
} 
#news { 
position: relative; 
    left: 80px; 
top: -261px; 
} 
#logo { 
position: relative; 
    left: -200px; 
} 
#vwlogo { 
position: relative; 
    right: -620px; 
top:-200px; 
} 

請解決這個問題。我應該繼續我的工作。

+0

會發生什麼需要?應該發生什麼? – Reeno

+0

究竟發生了什麼?鏈接指向哪裏?你的HTML似乎是有效的:) – Milkmannetje

+0

發生什麼事情是,按下的鏈接不會重定向到mywebpage.com/blah.html#,因爲它應該。 – geotsak

回答

0

我不明白第二個鏈接應該指向哪裏,但我認爲這是一些東西。

<div id="news"> 
    <a href="#news"> 
     <img src="/news.png" height="95" width="95"> 
     <br><b>NEWS</b> 
    </a> 
</div> 
+0

沒有得到它我很抱歉。 – geotsak

0

似乎沒有任何問題。試試不同的鏈接到不同的網站或不同的頁面。 #讓你在同一頁上,以便嘗試別的發送它放在

+0

試過它沒有工作。 – geotsak

0

如果使用#你可以在頁面內導航,例如檢查本網站上的內容鏈接:

http://www.w3.org/TR/html401/struct/links.html

它們看起來像這

<a class="tocxref" href="#h-12.1.1">Visiting a linked resource</a> 

如果使用無錨可以導航到任何網站例如

<a href="http://www.w3schools.com">Visit W3Schools.com!</a> 

請嘗試例如

<div id="logo"> 
    <img src="https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcQJEf2pg34Ls3yL7gvw-XYkVGvfgXb3_4fW8fyF1kfNYGPxyuoiuecq0VqQ" height="150" width="300"> 
</div> 
<div id="home"> 
    <a href="https://www.google.com" target="_blank"> 
     <img src="https://www.google.com.ar/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" height="95" width="95"> 
     <br> 
     <b>HOME</b> 
    </a> 
</div> 
<div id="news"> 
    <a href="https://www.google.com" target="_blank"> 
     <img src="https://www.google.com.ar/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png" height="95" width="95"> 
     <br><b>NEWS</b> 
    </a> 
</div> 

這個代碼,如果您刪除目標=「_空白」,你會被重定向到該網站,你在HREF

+0

沒有工作。此外,我忘記提及,當我將鼠標移到第一個鏈接的文本上時,它不會像您在其他鏈接上看到的那樣改變它。 – geotsak

+0

請嘗試使用我編輯的答案中的示例代碼,並告訴我它是否按照您的預期方式工作。 –

+0

嘗試沒有工作。 – geotsak