如何在汉堡菜单过渡后面隐藏/ z-索引按钮?

时间:2019-04-16 13:51:20

标签: html css

我在导航栏上设置了一个圆圈,单击了汉堡包后,圆圈会立即扩展。在“展开的圆圈下面是文本和按钮,我想将它们隐藏在圆圈后面。有关如何解决该问题的任何想法?

Z索引可能是? Javscript可以切换类并隐藏它们?

我不确定这里有什么好的解决方案。

CSS样式表


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

nav {
    display: flex;
    position: fixed;
    width: 100%;
    border: solid 3px white;
    height: 5vh;
    background: rgba(0, 0, 0, 0.2);
}

.home {
    background: url("Images/Workshop.jpg");
    background-size: cover;
    background-position: center;
    height: 100vh;
}

.nav-brand {
    display: flex;
}

.nav-brand a {
    padding-left: 3vh;
    display: flex;
    justify-content: space-around;
    align-items: center;
    color: white;
    font-size: 3vh;
    font-family: 'Lobster', cursive;
    text-decoration: none;
}

.nav-brand a:hover {
    color:  #00C9A7;
}

.nav-links {
    display: flex;
    list-style: none;
    width: 50%;
    height: 100%;
    justify-content: space-around;
    align-items: center;
    margin-left: auto;
}

.nav-item {
    color: white;
    text-decoration: none;
    font-size: 3vh;
    font-weight: bold;
}

.nav-item:hover {
    color: #00C9A7;
}

@media screen and (max-width: 768px) {
    .line1 {
        width: 30px;
        height: 3px;
        background: white;
        margin: 5px;
        transition: all 0.5s ease-in;
    }
    .line2 {
        width: 30px;
        height: 3px;
        background: white;
        margin: 5px;
        transition: all 0.5s ease;
    }
    .line3 {
        width: 30px;
        height: 3px;
        background: white;
        margin: 5px;
        transition: all 0.5s ease-in;
    }

    .hamburger {
        position: absolute;
        cursor: pointer;
        right: 5%;
        top: 50%;
        transform: translate(-5%, -50%);
        z-index: 2;
    }
    .nav-links {
        position: fixed;
        background: black;
        /* ! Margin solves the border problem */
        margin: -3px;
        height: 100%;
        width: 100%;
        flex-direction: column;
        clip-path: circle(100px at -15% -15%);
        -webkit-clip-path: circle(100px at -15% -15%);
        transition: all 1s ease-out;
        pointer-events: all;
    }
    .nav-links.open {
        clip-path: circle(1500px at -15% -15%);
        -webkit-clip-path: circle(1500px at -15% -15%);
    }

    .nav-links li {
        opacity: 0;
    }
    .nav-item {
        font-size: 4vh;
        font-family: 'Lobster', sans-serif;
        font-weight: 500;
    }
    .nav-links li:nth-child(1) {
        transition: all 0.5s ease 0.2s;
    }
    .nav-links li:nth-child(2) {
        transition: all 0.5s ease 0.3s;
    }
    .nav-links li:nth-child(3) {
        transition: all 0.5s ease 0.4s;
    }
    li.fade {
        opacity: 1;
    }
}

.toggle .line1 {
    transform: rotate(-45deg) translate(-5px, 6px);
}

.toggle .line2 {
    opacity: 0;
}

.toggle .line3 {
    transform: rotate(45deg) translate(-5px, -6px);
}

/* ! Content and Grid setup */

.content {
    display: flex;
    justify-content: center;
    padding: 15vh;

}

.content h1 {
    font-family: 'Yanone Kaffeesatz', sans-serif;
    font-size: 6vh;
    color: white;
    text-align: center;
    z-index: -1;
}

.btn {
    display: flex;
    justify-content: center;  
}

.btn a button{
    font-family: 'Yanone Kaffeesatz', sans-serif;
    font-weight: 500;
    font-size: 2.5vh;
    text-align: center;
    border: solid 2px;
    border-radius: 9px;
    border-color: red;
    background: red;
    color: white;
    padding: 10px 15px;
    transition: 0.25s ease;
}

.btn a button:hover {
    color: white;
    background:  #00C9A7;
    border-color: #00C9A7;
}

1 个答案:

答案 0 :(得分:0)

我用z-index解决了这个问题。我在nav中添加了z-index,并在.btn中添加了一个较低的值