Slider menu in html page using css
To create a slider navigation menu in html by using CSS syntax.
Copy the following program and paste in Notepad then save as .html file extension and view in browser.
<html> <style> body { font-family: "Tahoma", sans-serif; } .sidemenu { height: 100%; width: 0; position: fixed; top: 0; right: 0; background-color: #222; overflow-x: hidden; transition: 1s; padding-top: 50px; } .sidemenu a { padding: 9px 9px 9px 42px; text-decoration: none; font-size: 25px; color: #818181; display: block; transition: 0.3s } .sidemenu a:hover, .offcanvas a:focus{ color: #f1f1f1; } .sidemenu .closebtn { position: absolute; top: 0; right: 25px; font-size: 36px; margin-left: 50px; } </style> <body> <div id="mySidenav" class="sidemenu"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a> <a href="#">Web design</a> <a href="#">Digital Marketing</a> <a href="#">Mobile App</a> <a href="#">Contact</a> <img src="d:\web-design.jpg" height=100 width=100> <img src="d:\bing.jpg" height=100 width=100> <img src="d:\ubuntu.png" height=100 width=100> <img src="d:\java-logo.jpg" height=100 width=100> </div> <div align=right> <h2 align=right>Animated SideMenu Demo</h2> <span style="font-size:30px;cursor:pointer" onclick="openNav()">☰ Menu</span> <script> function openNav() { document.getElementById("mySidenav").style.width = "300px"; } function closeNav() { document.getElementById("mySidenav").style.width = "0"; } </script> </body> </html>
OutputĀ
Before opening Menu
After opening Menu