链接(<a>) doesn&#39;t work with images in absolute position

时间:2015-10-13 14:32:42

标签: html css

The link line 44 works only when I remove 'position absolute' from my images. I tryed with opera, firefox, IE, safary and chrome.

I tryed to change z-index of my link whithout any result.

You can see this issue by downloading images and code there : https://www.mediafire.com/folder/kn6wdothgbsms/html_problem

我也直接在此页面上复制/通过您的代码:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Document sans nom</title>

<style>

section>img:first-child
{
    position:absolute;
    left:0px; top:0;
}

section>img:nth-child(2)
{
    position:absolute;
    right:0px; top:0;
}

article
{
    padding:50px;
}

a
{
    z-index:10;
}

</style>

</head>

<body>

        <section>

            <img alt="article_end" src="main_top_left.png"/>
            <img alt="article_end" src="main_top_right.png"/>


            <article>
              <a href="www.google.fr">LINK</a> 
            </article>

        </section>   

</body>
</html>

1 个答案:

答案 0 :(得分:2)

Z-index仅适用于已设置position: absoluteposition: relative的元素;所以为了获得你的链接&#34;在#34;之上你的图像,你应该给它一个位置:亲戚。

工作示例:http://www.codeply.com/go/7Gog6kcwiC

另见z-index not working with position absolute