Skip to content
Related Articles
Open in App
Not now

Related Articles

How to cover the whole screen when the hamburger menu is pressed on smaller screens?

Improve Article
Save Article
  • Last Updated : 27 Aug, 2019
Improve Article
Save Article

Bootstrap provides a class to overlay the content and different style properties to make it appear more attractive. To fill the viewport or whole screen with .nav-bar change the height.

min-height: 100vh;


<!DOCTYPE html>
    <meta name="viewport" 
          content="width=device-width, initial-scale=1">
        body {
            font-family: 'Lato', sans-serif;
        .overlay {
            height: 100%;
            width: 0;
            position: fixed;
            background-color: rgb(255, 255, 255);
            background-color: rgba(0, 96, 128, 0.9);
            overflow-x: hidden;
            transition: 0.5s;
        .overlay-content {
            position: relative;
            top: 25%;
            width: 100%;
            text-align: center;
            margin-top: 30px;
        .overlay a {
            padding: 8px;
            text-decoration: none;
            font-size: 36px;
            color: #000000;
            display: block;
            transition: 0.3s;
        .overlay a:hover,
        .overlay a:focus {
            color: #f1f1f1;
        .overlay .closebtn {
            position: absolute;
            top: 20px;
            right: 45px;
            font-size: 60px;
        @media screen and (max-height: 450px) {
            .overlay a {
                font-size: 20px
            .overlay .closebtn {
                font-size: 40px;
                top: 15px;
                right: 35px;
    <div id="myNav" class="overlay">
        <a href="javascript:void(0)" 
        <div class="overlay-content">
            <a href="#">Login</a>
            <a href="#">SignUp</a>
            <a href="#">AboutUs</a>
            <a href="#">ContactUs</a>
    <h2 style="background-color:green; 
               height:40px ">GeeksforGeeks
<span style="font-size:30px;
             float:right; "
    <h1 style="text-align:center; 
               color:green">Overlay the content</h1>
        function openNav() {
              "myNav").style.width = "100%";
        function closeNav() {
              "myNav").style.width = "0%";

Desktop View:

Mobile View:

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!