Skip to content

Commit 063cd9c

Browse files
committed
Add a menu button in the mobile view
1 parent 214a2b9 commit 063cd9c

5 files changed

Lines changed: 71 additions & 41 deletions

File tree

_includes/head.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
88
<script src="{{ site.github.url }}/javascripts/respond.js"></script>
99
<script src="{{ site.github.url }}/javascripts/cards.js"></script>
10+
<script src="{{ site.github.url }}/javascripts/menu.js"></script>
1011
<!--[if lt IE 9]>
1112
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
1213
<![endif]-->

_includes/header.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
<div id="header">
1+
<div id="header" class="mobile-hidden">
22
<nav>
3+
<li class="nav-menu">
4+
<img src="{{ site.github.url }}/images/menu.png" />
5+
</li>
6+
37
<li class="left button">
48
<a href="{{ site.github.url }}/" title="There's no place like Home...">Home</a>
59
</li>

images/menu.png

2.78 KB
Loading

javascripts/menu.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$(document).ready(function () {
2+
var headerHeight = $('#header').height();
3+
4+
$('.nav-menu').click(function () {
5+
if ($('#header').height() <= 50) {
6+
7+
$('#header').removeClass('mobile-hidden');
8+
$('#header').animate({ height: 396 }, 400, function () {
9+
$('#header').height('auto');
10+
});
11+
}
12+
else
13+
$('#header').animate({ height: headerHeight }, 400, 'swing', function () {
14+
$('#header').addClass('mobile-hidden');
15+
$('#header').css('height', '');
16+
});
17+
});
18+
});

stylesheets/styles.css

Lines changed: 47 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,17 @@ dt {
814814
box-shadow: inset 0px 1px 1px rgba(0, 0, 0, 0.2), 0px 1px 0px rgba(0, 0, 0, 0);
815815
}
816816

817+
.nav-menu {
818+
list-style: none;
819+
display: none;
820+
line-height: 50px;
821+
height: 50px;
822+
padding: 8px 6px;
823+
824+
cursor: pointer;
825+
float: right;
826+
}
827+
817828
#header nav li.left {
818829
float: left;
819830
margin-right: 6px;
@@ -1009,58 +1020,54 @@ section #title p {
10091020
display: block;
10101021
}
10111022
}
1023+
10121024
@media print, screen and (max-width: 590px) {
1013-
#header {
1014-
margin: 0 auto;
1015-
position: relative;
1016-
padding: 0 20px;
1017-
1018-
height: auto;
1019-
width: auto;
1020-
1021-
left: auto;
1022-
top: auto;
1023-
right: auto;
1024-
1025-
background: none;
1026-
border: none;
1027-
-moz-box-shadow: none;
1028-
-webkit-box-shadow: none;
1029-
-o-box-shadow: none;
1030-
box-shadow: none;
1031-
}
1025+
#header {
1026+
margin: -20px auto 0 auto;
1027+
position: relative;
1028+
padding: 0 20px;
1029+
height: 50px;
1030+
width: auto;
1031+
left: auto;
1032+
top: auto;
1033+
right: auto;
1034+
}
10321035

1033-
section {
1034-
margin-top: 10px;
1035-
}
1036+
section {
1037+
margin-top: 10px;
1038+
}
10361039

1037-
#header nav {
1038-
padding: 0 0 0 0;
1039-
margin: 0 26px 0 0;
1040-
}
1040+
#header nav {
1041+
padding: 0 0 0 0;
1042+
margin: 0 0 0 0;
1043+
}
10411044

1042-
#header nav .button {
1043-
float: none !important;
1044-
display: block;
1045-
margin-left: 0 !important;
1046-
margin-right: 0 !important;
1047-
}
1045+
#header nav .button {
1046+
float: none !important;
1047+
display: block;
1048+
margin-left: 0 !important;
1049+
margin-right: 26px !important;
1050+
}
10481051

10491052
#header nav > .right {
10501053
padding-top: 30px;
10511054
}
10521055

1053-
#header nav > .right ~ .right {
1054-
padding-top: 0;
1056+
#header nav > .right ~ .right {
1057+
padding-top: 0;
1058+
}
1059+
1060+
#header nav .button a {
1061+
width: 100%;
10551062
}
10561063

1057-
#header nav .button a {
1058-
width: 100%;
1059-
}
1064+
.nav-menu {
1065+
display: inline;
1066+
}
10601067

1061-
/*#header nav .button.right {
1062-
display: none;
1063-
}*/
1068+
#header.mobile-hidden nav .button {
1069+
display: none;
1070+
}
10641071
}
10651072

10661073
:target {

0 commit comments

Comments
 (0)