If you are looking to implement the w3-sidebar, you can find it here: https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_sidebar_over
The existing code uses a "hanburger" icon to open the side menu and a "Close X" menu item to close it.
To simplify the process, I want to use the same "hanburger" icon for both opening and closing the menu. To keep the hanburger always visible, I have included the following CSS:
.w3-sidebar {
margin-top: 42px;
}
Here is the snippet of code for reference:
function w3_open() {
document.getElementById("mySidebar").style.display = "block";
}
function w3_close() {
document.getElementById("mySidebar").style.display = "none";
}
<!DOCTYPE html>
<html>
<head>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
</head>
<body>
<!-- Sidebar -->
<div class="w3-sidebar w3-bar-block w3-border-right" style="display:none" id="mySidebar">
<button onclick="w3_close()" class="w3-bar-item w3-large">Close ×</button>
<a href="#" class="w3-bar-item w3-button">Link 1</a>
<a href="#" class="w3-bar-item w3-button">Link 2</a>
<a href="#" class="w3-bar-item w3-button">Link 3</a>
</div>
<!-- Page Content -->
<div class="w3-teal">
<button class="w3-button w3-teal w3-xlarge" onclick="w3_open()">☰</button>
<div class="w3-container">
<h1>My Page</h1>
</div>
</div>
<img src="img_car.jpg" alt="Car" style="width:100%">
<div class="w3-container">
<p>By default, this sidebar is hidden (style="display:none")</p>
<p>To reveal it, simply click on the "hamburger" icon in the top left corner.</p>
<p>The sidebar will cover part of the page's content when opened.</p>
</div>
</body>
</html>