簡體   English   中英

<a>標簽無效</a>

[英]<a> Tag Doesn't work

我有一個帶有兩個標簽的代碼。 第一個無效,而第二個有效。 為什么? 這是我的代碼:

<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;
}

請解決此問題。 我真的應該繼續我的工作。

我不知道第二個鏈接應該指向何處,但是我認為這是正確的。

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

似乎沒有任何問題。 嘗試使用不同的鏈接指向不同的站點或不同的頁面。 #使您保持在同一頁面上,因此請嘗試將其發送到其他位置

如果使用#,則可以在頁面內導航,例如,檢查此站點中的內容鏈接:

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> 

如果刪除target =“ _ blank”,您將被重定向到href中需要的站點

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM