This side menu is a very simple example with HTML5, CSS, and jQuery.
The result is this:
You can see the source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | <!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Side menu example</title> <style> body { margin: 0; background-color:#ffffff; font-family:'Comics';} .pushmenu { /*this is the menu*/ background: #6699ff; text-align: center; width: 200px; height: 100%; top: 0; z-index: 1000; position: fixed; } .pushmenu h3 { color: #f1f1f1; font-size: 1em; font-weight: 400; padding: 15px 25px; margin: 0; background: #6699ff; height: 16px; } .links { list-style-type: none; padding: 0; } .links li { margin-top: 10px; } .links li a { position: relative; display: block; /* drops the menu vertically*/ color: #ffffff; font-size: 1em; font-weight: 400; text-decoration: none; padding: 5px; } .links li a:after { content: ''; display: block; position: absolute; left: 20px; bottom: -5px; width: 0; height: 5px; background-color: #ffffff; -webkit-transition: width 0.3s ease; -moz-transition: width 0.3s ease; transition: width 0.3s ease; } .links li a:hover:after { width: 80%; } .links li a:active { color: #0066ff; } .pushmenu-left { left: -200px; } .pushmenu-left.pushmenu-open { left: 0; } .pushmenu-push { overflow-x: hidden; position: relative; left: 0; } .pushmenu-push-toright { left: 200px; } /*Transition effect */ .pushmenu, .pushmenu-push { -webkit-transition: all 0.5s ease; -moz-transition: all 0.5s ease; transition: all 0.5s ease; } #nav_list { background: url(icon.png) no-repeat left top; cursor: pointer; height: 27px; text-indent: -99999em; } nav-list.active { background-position: -231px top; } .buttonset { background: #003399; height: 16px; padding: 10px 20px 20px; } section.content { padding: 10px 20px; white-space:wrap; }</style> <script src="https://code.jquery.com/jquery-3.2.0.min.js"></script> </head> <body class="pushmenu-push"> <nav class="pushmenu pushmenu-left"> <h3>Logo text</h3> <ul class="links"> <li> <a href="#">Home</a> </li> <li> <a href="#">About</a> </li> <li> <a href="#">Projects</a> </li> <li> <a href="#">Blog</a> </li> <li> <a href="#">Contacts</a> </li> </ul> </nav> <div class="container"> <div class="main"> <section class="buttonset"> <div id="nav_list">MENU</div> </section> <section class="content"> <h1>Press to button to see the menu !</h1> <p> Simple side menu example </p> </section> </div> </div> <script type="text/javascript">$(document).ready(function() { $menuLeft = $('.pushmenu-left'); $nav_list = $('#nav_list'); $nav_list.click(function() { $(this).toggleClass('active'); $('.pushmenu-push').toggleClass('pushmenu-push-toright'); $menuLeft.toggleClass('pushmenu-open'); }); });</script> </body> </html> |