Edit This Code:
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../lib/w3.css">
<body>

<nav class="w3-sidenav w3-white w3-animate-left" style="display:none;z-index:5">
  <a href="javascript:void(0)" onclick="w3_close()"
  class="w3-closenav w3-large"
>
Close &times;</a>
  <a href="tryit.asp-filename=tryw3css_ref_sidenav_overlay_class.html#">Link 1</a>                
  <a href="tryit.asp-filename=tryw3css_ref_sidenav_overlay_class.html#">Link 2</a>                
  <a href="tryit.asp-filename=tryw3css_ref_sidenav_overlay_class.html#">Link 3</a>                
  <a href="tryit.asp-filename=tryw3css_ref_sidenav_overlay_class.html#">Link 4</a>                
  <a href="tryit.asp-filename=tryw3css_ref_sidenav_overlay_class.html#">Link 5</a>                
</nav>

<div class="w3-overlay w3-animate-opacity" onclick="w3_close()" style="cursor:pointer"></div>

<div class="w3-container">
  <span class="w3-opennav w3-xxlarge" onclick="w3_open()">&#9776;</span>
  <h2>Page content..</h2>
  <p>The w3-overlay class can be used to create an overlay effect, when opening the sidenav. The w3-overlay class adds a black background with a 50% opacity to the "page content" - this effect will "highlight" the side navigation</p>
  <p>Click on the menu icon (&#9776;) to see the effect.</p>
</div>  
    
<script>
function w3_open() {
    document.getElementsByClassName("w3-sidenav")[0].style.display = "block";
    document.getElementsByClassName("w3-overlay")[0].style.display = "block";
}
function w3_close() {
    document.getElementsByClassName("w3-sidenav")[0].style.display = "none";
    document.getElementsByClassName("w3-overlay")[0].style.display = "none";
}
</script>
          
</body>
</html>


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