href链接不适用于图像

时间:2015-04-27 09:01:33

标签: html css href

我需要一点帮助...... 我无法理解为什么我的图片上的链接不起作用... 我一直在寻找这么长时间,但我找不到它为什么不起作用的原因!请帮我... 非常感谢你!

.container {
	width: 80%;
	max-width: 1240px; /*maks bredde*/
	min-height: 500px;
	margin: 0 auto; /*midtstiller container og setter den øverst*/
}


header {
	background-color: #292929;
	width: 80%;
	position: fixed;
	margin-top: 5px;
}


header img{
	width: 8%;
	float: left;
	margin-left: 20px;
	margin-top: 15px;
	margin-bottom: 15px;
	height: 4%;
}


#navlogoer {
	width: 40%;
	margin-left: 75%;
	margin-top: -65px;
}
<div class="container">

    <header>
        <a href="index.html">
            <img src="images/Opheimlogooransje.png" alt="opheim logo"/></a>
        <nav id="navlogoer">
            <a href="https://itunes.apple.com/no/album/summerbeach-feat.-tiril-sundf/id981300584?i=981300598&uo=6&at=&ct=">
                <img src="images/ITuneslogocroped.png" alt="Itunes logo"/></a>
            <a href="https://open.spotify.com/artist/0VaCp9BRPhNezjr5Z3va5l">
                <img src="images/Spotifylogocroped.png" alt="Spotify logo"/></a>
            <a href="https://www.youtube.com/channel/UCohhdrYONwzIeMW61Ibgszw/feed">
                <img src="images/youtubelogocroped.png" alt="Youtube logo"/></a>
            <a href="https://soundcloud.com/jesperopheim">
                <img src="images/Soundcloudlogocroped.png" alt="Soundcloud"/></a>
            <a href="https://no.7digital.com/artist/opheim/">
                <img src="images/7digitallogocroped.png" alt="7digital logo"/></a>
        </nav>
    </header>

</div>

3 个答案:

答案 0 :(得分:1)

根据您的问题,所有链接都正常工作。实际上,将图像作为链接的正确语法如下:

<pre><code><a href="#"><img src="" alt="" /></a></code></pre>

答案 1 :(得分:0)

嘿,你这里做错了什么

header img{
    width: 8%;
    float: left;
    margin-left: 20px;
    margin-top: 15px;
    margin-bottom: 15px;
    height: 4%;
}

将其更改为

header a{
    width: 8%;
    float: left;
    margin-left: 20px;
    margin-top: 15px;
    margin-bottom: 15px;
    height: 4%;
display:block;
}

header img{
    width: 100%;

}

答案 2 :(得分:0)

您的代码运行正常,我查了一下。

以下是示例DEMO

我只是替换了图片。

因此,请检查图像的位置。

<div class="container">

<header>
    <a href="index.html">
        <img src="http://s17.postimg.org/ahbud601n/klematis2.jpg" alt="opheim logo"/></a>


        <nav id="navlogoer">
            <a href="https://itunes.apple.com/no/album/summerbeach-feat.-tiril-sundf/id981300584?i=981300598&uo=6&at=&ct=">
                <img src="images/ITuneslogocroped.png" alt="Itunes logo"/></a>
            <a href="https://open.spotify.com/artist/0VaCp9BRPhNezjr5Z3va5l">
            <img src="images/Spotifylogocroped.png" alt="Spotify logo"/></a>
            <a href="https://www.youtube.com/channel/UCohhdrYONwzIeMW61Ibgszw/feed">
                <img src="http://s17.postimg.org/ahbud601n/klematis2.jpg" alt="Youtube logo"/></a>
            <a href="https://soundcloud.com/jesperopheim">
                <img src="http://s17.postimg.org/ahbud601n/klematis2.jpg" alt="Soundcloud"/></a>
            <a href="https://no.7digital.com/artist/opheim/">
                <img src="http://s17.postimg.org/ahbud601n/klematis2.jpg" alt="7digital logo"/></a>
                </nav>
                </header>        

</div>

</body>
</html>