Skip to content

Instantly share code, notes, and snippets.

@tschiemer
Last active February 18, 2016 14:20
Show Gist options
  • Save tschiemer/f887608fa94911a1f451 to your computer and use it in GitHub Desktop.
Save tschiemer/f887608fa94911a1f451 to your computer and use it in GitHub Desktop.
HelpDeskZ foldable, responsive menu example
CHANGE:
//from
...
input[type="button"], input[type="submit"]{
...
//to
...
input[type="button"], input[type="submit"], button {
..
NEW:
#logo {
float: left;
display: inline-block;
}
#navbar-responsive {
display: none;
float: right;
margin: 10px;
}
@media (max-width: 640px) {
#navbar {display:none}
#navbar.expanded {display:block}
}
@media (max-width: 640px) {
#navbar-responsive {display: inline-block;}
}
function toggleMenu(){
if ($('#navbar').hasClass('expanded')){
$('#navbar').removeClass('expanded');
} else {
$('#navbar').addClass('expanded');
}
}
// the menu is expanded by default because not everybody has JS enabled, thus for all those who have it enabled, fold menu
$(document).ready(function(){
$('#navbar').removeClass('expanded');
});
Assumed you have downloaded and installed icons from http://genericons.com/ into css folder
<head>
...
<link href="{{ settings.site_url }}/css/style.css" rel="stylesheet" type="text/css" />
<!-- NEW --> <link href="{{ settings.site_url }}/css/genericons.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="{{ settings.site_url }}/js/jquery.js"></script>
<!-- NEW --> <script type="text/javascript" src="{{ settings.site_url }}/js/site.js"></script>
...
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="logo">
<a href="{{ settings.site_url }}"></a>
</div>
<!-- NEW start-->
<div id="navbar-responsive">
<button onclick="toggleMenu();"><span class="genericon genericon-menu"></span></button>
</div>
<div class="clear"></div>
<!-- NEW end -->
</div>
<div id="navbar" class="expanded"> <-- add class expanded as a default -->
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment