JSFiddle - React, Tailwind, and code Playground

by Lalji Tadhani

HTML

<div id="navbar">
        <div id="logo">
            <a href="#">
                <h1>Braindotai</h1>
            </a>
        </div>
        <ul id="menu">
            <li><a class="link-button" href="#">HOME</a></li>
            <li><a class="link-button" href="#">ARTICLES</a></li>
            <li><a class="link-button" href="#">PROJECTS</a></li>
            <li><a class="link-button" href="#">AUTHOR</a></li>
            <li><a class="link-button" href="#">CONTACT</a></li>
        </ul>
    </div>

    <div id="welcome">
        <h1 id="welcome-text">My Portfolio</h1>
    </div>

    <div class="container">
    </div>

CSS

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: sans-serif;
}

body{
    height: 100vh;
    perspective: 1px;
    transform-style: preserve-3d;
    overflow-x: hidden;
    overflow-y: auto;
}

html{
    overflow: hidden;
}

#navbar{
    position: sticky;
    width: 100%;
    top: 0;
    transition: background 0.5s;
    background-color: transparent;
    z-index: 2;
}

#navbar #logo{
    float: left;
    margin: 10px;
}

#navbar #logo a{
    font-size: 155%;
    color: #ffffff;
    text-decoration: none;
}

#navbar ul{
    float: right;
    justify-content: space-around;
    list-style: none;
    align-items: center;
    padding: 20px;
}

#navbar ul li{
    display: inline-block;
}

/* === Here I'm changing the display property of the navbar to none to make it disappear. === */

#navbar.navbar-scroll{
    display: none;
}

.link-button{
    display: block;
    text-align: center;
    margin: 0 15px;
    font-size: 89%;
    color: #ffffff;
    text-decoration: none;
}

.link-button::after{
    content: '';
    display: block;
    width: 0;
    height: 2px;
    margin-top: 2px;
    background: #ffffff;
    transition: width .3s;
}

.link-button:hover::after{
    width: 100%;
    transition: width .3s;
}

#welcome{
    height: 100vh;
    width: 100vw;
    box-sizing: border-box;
}

#welcome::before{
    content: "";
    height: 100vh;
    width: 100vw;
    top: 0;
    left: 0;
    background: linear-gradient(#0000008e, #0000008e), url('static/bc22.jpg');
    background-position: center;
    -webkit-background-size: cover;
    -moz-background-size:  cover;
    -o-background-size: cover;
    background-size: cover;
    position: absolute;
    z-index: -1;
    transform: translateZ(-2px) scale(3);
}

#welcome-text{
    color: #ffffff;
    position: absolute;
    top: 50%;
    left: 26%;
    transform: translate(-50%, -50%);
    /* text-align: center; */
    font-size: 600%;
}


.container{
    background-color: #1f1f1f;
    height: 1000px;
}

JavaScript

window.addEventListener("scroll", function(){
            let Navbar = document.getElementById('navbar');
            if(window.pageYOffset < 30){
                Navbar.classList.add("navbar-scroll");
            }else{
                Navbar.classList.remove("navbar-scroll");
            }
        });