简体   繁体   中英

How to hide/z-index a button behind a hamburger menu transition?

I made a navbar transition with a circle that expands as soon as the hamburger is clicked. Under the "expanding circle is a text and a button below and i want to hide them behind the circle. Any ideas about how to solve that?

Z-Index maybe ? Javscript that toggles the classes and hides them ?

I am not sure what is a good solution here.

CSS Stylesheet


* {
    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;
}

I solved the problem with z-index. I added a z-index to nav and a lower value to the .btn

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM