Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
body {margin: 0;}

ul.sidenav {
    list-style-type: none;
    margin: 0;
    padding: 0;
    width: 25%;
    background-color: #f1f1f1;
    position: fixed;
    height: 100%;
    overflow: auto;
}


ul.sidenav li a {
    display: block;
    color: #000;
    padding: 8px 0 8px 16px;
    text-decoration: none;
}

 
ul.sidenav li a.active {
    background-color: #4CAF50;
    color: white;
}


ul.sidenav li a:hover:not(.active) {
    background-color: #555;
    color: white;
}


div.content {
    margin-left: 25%;
    padding: 1px 16px;
    height: 1000px;
}


@media screen and (max-width: 600px){
    ul.sidenav {
        width:100%;
        height:auto;
        position:relative;
    }

    ul.sidenav li a {
        float: left;
        padding: 15px;
    }

    div.content {margin-left:0;}
}

@media screen and (max-width: 400px){
    ul.sidenav li a {
        text-align: center;
        float: none;
    }

}
</style>
</head>
<body>

<ul class="sidenav">
  <li><a class="active" href="tryit.asp-filename=trycss_navbar_vertical_responsive.html#home">Home</a></li>
  <li><a href="tryit.asp-filename=trycss_navbar_vertical_responsive.html#news">News</a></li>
  <li><a href="tryit.asp-filename=trycss_navbar_vertical_responsive.html#contact">Contact</a></li>
  <li><a href="tryit.asp-filename=trycss_navbar_vertical_responsive.html#about">About</a></li>
</ul>

<div class="content">
  <h2>Responsive Sidenav Example</h2>
  <p>This example use media queries to transform the sidenav to a top navigation bar when the screen size is 600px or less.</p>
  <p>We have also added a media query for screens that are 400px or less, which will vertically stack and center the navigation links.</p>
  <p>You will learn more about media queries and responsive web design later in our CSS Tutorial.</p>
  <h4>Resize the browser window to see the effect.</h4>
</div>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy