Skip to content

Instantly share code, notes, and snippets.

@tararoutray
Last active August 4, 2022 14:20
Show Gist options
  • Save tararoutray/b949d8a7522f01edb07017b7a09299a9 to your computer and use it in GitHub Desktop.
Save tararoutray/b949d8a7522f01edb07017b7a09299a9 to your computer and use it in GitHub Desktop.
<div id="mySidebar" class="sidebar">
<a href="javascript:void(0)" class="closebtn" onclick="closeSidebar()">&times;</a>
<a href="#">About</a>
<a href="#">Services</a>
<a href="#">Clients</a>
<a href="#">Contact</a>
</div>
<div id="main">
<button class="openbtn" onclick="openSidebar()">&#9776; Open Sidebar</button>
<h1>Animated Sidebar Using HTML, CSS, and JavaScript</h1>
<div class="">
Click the above button to open the sidebar menu.
</div>
</div>
@jameelmoses
Copy link

Per my comment on Medium for a11y improvement:

<div id="mySidebar" class="sidebar" aria-hidden="true">
    <button type="button" class="closebtn" onclick="closeSidebar()" aria-controls="mySidebar">&times;</a>
    <a href="#">About</a>
    <a href="#">Services</a>
    <a href="#">Clients</a>
    <a href="#">Contact</a>
</div>

<div id="main">
    <button type="button" class="openbtn" onclick="openSidebar()" aria-controls="mySidebar" aria-expanded="false">&#9776; Open Sidebar</button>
    <h1>Animated Sidebar Using  HTML, CSS, and JavaScript</h1>
    <div class="">
        Click the above button to open the sidebar menu.
    </div>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment