DEV Community

Simplified Dev
Simplified Dev

Posted on

Fullscreen Overlay Navbar Using only HTML & CSS

In today’s article, we will show you how can create a Full overlay navigation bar menu using HTML & CSS Only

A full-page navigation menu that pushes the current content off the screen. A website menu is a collection of connected objects that aid in moving between the many pages or parts of a website. There are several types of menus, based on the content and structure of the website.

In this program at the left corner, there is a hamburger menu when we click on this menu bar button Navbar will be shown. This design is fully based on only HTML & CSS.

Project Demo: https://fullscreen-navbar-overlay.netlify.app/

HTML Code For Overlay Navbar

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

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Navbar Overlay</title>
    <link rel="stylesheet" href="style.css">

</head>

<body>
    <div class="container">
        <div class="content">
            <h2>Welcome</h2>
            <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the
                industry's standard.</p>
            <a href="#" class="btn">Learn more</a>
        </div>
    </div>

    <div class="nav">
        <input type="checkbox" class="toggle">
        <div class="hamburger">
            <div></div>
        </div>
        <div class="nav_menu">
            <div>
                <div>

                    <ul>
                        <li><a href="#">Home</a></li>
                        <li><a href="#">Services</a></li>
                        <li><a href="#">Skills</a></li>
                        <li><a href="#">About Us</a></li>
                        <li><a href="#">Contact Us</a></li>

                    </ul>
                </div>
            </div>
        </div>
    </div>


</body>

</html>
Enter fullscreen mode Exit fullscreen mode

CSS Code For Overlay Navbar

@import url('https://fonts.googleapis.com/css?family=Dancing+Script:700|Roboto&display=swap');

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

body {
    --main-color: crimson;
    font-family: 'Roboto', sans-serif;
    overflow: hidden;
}

.container {
    position: relative;
    height: 100vh;
    width: 100vw;
    background: url("../img/bg.jpg") no-repeat;
    background-size: cover;
    background-position: 50% 36%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.container:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
}

.content {
    position: relative;
    max-width: 700px;
    padding: 2rem;
    z-index: 1;
}

.content h2 {
    color: var(--main-color);
    font-family: "Dancing Script", cursive;
    font-size: 4.3rem;
    margin-bottom: 0.8rem;
}

.content p {
    color: white;
    font-size: 1.2rem;
    font-weight: 100;
}

.btn {
    padding: 0.75rem 1.25rem;
    text-transform: uppercase;
    color: var(--main-color);
    font-weight: 550;
    font-size: 1.1rem;
    text-decoration: none;
    background-color: #111;
    display: inline-block;
    margin-top: .8rem;
    cursor: pointer;
    transition: .3s;
    border-radius: 10px;
}

.btn:hover {
    opacity: 0.8;
    box-shadow: 0px 0px 10px 0px grey;
}


.nav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2;
}

.toggle {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 60px;
    height: 60px;
    z-index: 3;
    opacity: 0;
    cursor: pointer;
}

.hamburger {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 60px;
    height: 60px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #111;
}

.hamburger>div {
    position: absolute;
    width: 60%;
    height: 3px;
    border-radius: 1.5px;
    background-color: var(--main-color);
    transition: .4s;
}

.hamburger>div:before {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    border-radius: 1.5px;
    background-color: var(--main-color);
    top: -10px;
    left: 0;
    transition: .4s;
}

.hamburger>div:after {
    content: '';
    position: absolute;
    width: 100%;
    height: 3px;
    border-radius: 1.5px;
    background-color: var(--main-color);
    top: 10px;
    left: 0;
    transition: .4s;
}

.toggle:checked+.hamburger>div {
    transform: rotate(135deg);
}

.toggle:checked:hover+.hamburger>div {
    transform: rotate(225deg);
}

.toggle:checked+.hamburger>div:before,
.toggle:checked+.hamburger>div:after {
    top: 0;
    transform: rotate(90deg);
}

.nav_menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    visibility: hidden;
    transition: .5s;
}

.nav_menu>div {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-150%) translateY(-50%);
    width: 1600px;
    height: 1600px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: .5s;
}

.nav_menu>div>div {
    max-width: 90vw;
    max-height: 100vh;
    opacity: 0;
    transition: .5s;
}

.nav_menu>div>div>ul>li {
    list-style: none;
}

.nav_menu>div>div>ul>li>a {
    text-decoration: none;
    color: #fff;
    font-weight: 550;
    text-transform: uppercase;
    margin: 0.5rem;
    transition: 0.4s;
    font-size: 1.3rem;
    display: inline-block;
}

.nav_menu>div>div>ul>li>a:hover {
    color: var(--main-color);
}


.toggle:checked~.nav_menu {
    visibility: visible;
}

.toggle:checked~.nav_menu>div {
    transform: translateX(-50%) translateY(-50%);
}

.toggle:checked~.nav_menu>div>div {
    opacity: 1;
}
Enter fullscreen mode Exit fullscreen mode

That’s it; you’ve now developed a Full Screen Navbar Using Html and CSS.

If you want to download the source code then visit our website:- blog.thesimplifieddev.com

Top comments (0)