<a> Tag Doesn&#39;t work

时间:2015-11-04 18:43:19

标签: html css

I have a code which has two tags. The first one doesn't work while the second one works. Why? Here is my code:

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

Here is my page's 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;
}

Please resolve this. I should really continue my work.

3 个答案:

答案 0 :(得分:0)

我不明白应该指向第二个链接的位置,但我认为这是事情。

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

答案 1 :(得分:0)

似乎没有任何问题。尝试使用指向其他网站或其他网页的其他链接。 #让你在同一页面上,所以尝试将其发送到

答案 2 :(得分: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> 

如果删除target =“_ blank”,您将被重定向到href中所需的网站