CSS z-index与链接冲突

时间:2016-05-18 19:58:53

标签: html css hyperlink menu z-index

我正在建立一个网站,我需要在前面有一个图像和它背后的一些链接,但当我这样做,使用z索引,我不能再点击链接,我试图改变链接的索引高于图片索引,我仍然无法点击...

html:

<!DOCTYPE html>
<html lang="">

<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<meta name="Author" content="" />
<link rel="stylesheet" type="text/css" href="styles.css">
</head>

<body>

<div class="container">

    <div class="milhoes">
        <div class="milhoes_img_cont">
            <img class="milhoes_img" src="milhoes.png" alt="">
        </div>

        <div class="left-menu">
            <div class="menu-item" id="menu-primeiro">
                <a href="">CARTAZ</a>
            </div>
            <div class="menu-item" id="menu-segundo">
                <a href="">INFO</a>
            </div>
            <div class="menu-item" id="menu-terceiro">
                <a href="">CONTACTOS</a>
            </div>
        </div>

            <div class="right-menu">
                <div class="menu-item" id="menu-primeiro-r">
                    <a href="">BILHETES</a>
                </div>
                <div class="menu-item" id="menu-segundo-r">
                    <a href="">LOJA</a>
                </div>
                <div class="menu-item" id="menu-terceiro-r">
                    <a href="">FESTIVAL</a>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

css:

@media screen and (max-width: 1028px) {
.container {
    background-color: pink;
}
}

@media screen and (max-width: 1024px) {
.container {
    background-color: blue;
}
}

@media screen and (max-width: 800px) {
.container {
    background-color: red;
}
}

@media screen and (max-width: 640px) {
.container {
    background-color: green;
}
}

@media screen and (max-width: 320px) {
.container {
    background-color: yellow;
}
}


html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}

.container {
width: 100%;
height: 100%;
background-color: black;
background-image: url(palco.jpg);
background-size: cover;
position: absolute;
top: 0;
left: 0;
z-index: -5;
}

.milhoes {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}

.menu-item {
height: 45px;
margin-bottom: 100px;
z-index: 100;
}

.milhoes_img {
height: 100%;
}

.milhoes_img_cont {
width: 100%;
height: 90%;
position: fixed;
z-index: 1;
margin-top: 2%;
}

.milhoes_img_cont img {
margin-left: auto;
margin-right: auto;
display: block;
}

.left-menu {
top: 10%;
left: 20%;
position: fixed;
z-index: 0;
}



#menu-primeiro {
-ms-transform: rotate(7deg);
-moz-transform: rotate(7deg);
-webkit-transform: rotate(7deg);
transform: rotate(7deg);
-webkit-backface-visibility: hidden;
background-color: #e41e25;
width: 300px;
margin-top: 50px;

}

#menu-segundo {
-ms-transform: rotate(-15deg);
-moz-transform: rotate(-15deg);
-webkit-transform: rotate(-15deg);
transform: rotate(-15deg);
-webkit-backface-visibility: hidden;
margin-left: 20px;
background-color: #e41e25;
width: 400px;
margin-top: 150px;

}

#menu-terceiro {
-ms-transform: rotate(-2deg);
-moz-transform: rotate(-2deg);
-webkit-transform: rotate(-2deg);
transform: rotate(-2deg);
-webkit-backface-visibility: hidden;
margin-left: 40px;
background-color: #5bc7d2;
width: 350px;
margin-top: 150px;
}


.right-menu {
top: 10%;
right: 10%;
position: fixed;
width: auto;
text-align: right;
z-index: 0;
}


#menu-primeiro-r {
-ms-transform: rotate(-12deg);
-moz-transform: rotate(-12deg);
-webkit-transform: rotate(-12deg);
transform: rotate(-12deg);
-webkit-backface-visibility: hidden;
background-color: #5bc7d2;
width: 350px;
margin-top: 50px;
margin-left: 100px;

}

#menu-segundo-r {
-ms-transform: rotate(2deg);
-moz-transform: rotate(2deg);
-webkit-transform: rotate(2deg);
transform: rotate(2deg);
-webkit-backface-visibility: hidden;
background-color: #e41e25;
width: 400px;
margin-top: 150px;
margin-left: 60px;


}

#menu-terceiro-r {
-ms-transform: rotate(15deg);
-moz-transform: rotate(15deg);
-webkit-transform: rotate(15deg);
transform: rotate(15deg);
-webkit-backface-visibility: hidden;
background-color: #5bc7d2;
width: 350px;
margin-top: 120px;
margin-right: 160px;

}

.right-menu a{
z-index: 120;
}

.menu-item a{
color: white;
line-height: 40px;
text-decoration: none;
font-size: 1.5em;
padding: 0 15px 0 15px;
font-family: Roboto, Arial, sans-serif;
}

这是Pen for it

2 个答案:

答案 0 :(得分:1)

我刚刚删除了所有z索引,它似乎工作正常。

除非我遗漏了什么。

答案 1 :(得分:1)

查看for (int i = 0; i < 9; ++i) { if (arr1[i/3][i%3] == arr2[i/3][i%3]) { /* print result */ }; } 它将允许您点击重叠元素。