Skip to content

Commit d2f462d

Browse files
committed
Animated side menu
1 parent 1d3b5b2 commit d2f462d

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

materials/appendixA/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<body>
1414
<header>
1515
<button id="menu"><svg height="32px" viewBox="0 0 32 32" width="32px"><path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z"/></svg></button>
16+
<span>Pro React - Appendix A</span>
1617
</header>
1718
<nav>
1819
<a href="http://www.pro-react.com">

materials/appendixA/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ var navVisible = false;
22
$('#menu').click(function(e){
33
if(navVisible){
44
navVisible = false;
5-
$('nav').hide();
5+
$('nav').removeClass('open');
66
} else {
77
navVisible = true;
8-
$('nav').show();
8+
$('nav').addClass('open');
99
}
1010
});
1111

@@ -20,8 +20,8 @@ $(window).on('resize', function(){
2020

2121
function moveNavigation(){
2222
if($(window).width()>1023){
23-
$('nav').show();
24-
navVisible = true;
23+
$('nav').removeClass('open');
24+
navVisible = false;
2525

2626
}
2727
resizing = false;

materials/appendixA/styles.css

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ header button svg {
140140
fill: #ffffff;
141141
}
142142

143+
header span{
144+
display: block;
145+
position: absolute;
146+
top: 20%;
147+
transform: translateY(-50%);
148+
left: 50%;
149+
transform: translateX(-50%);
150+
font-family: 'Montserrat', "Lucida Grande","Lucida Sans Unicode","Lucida Sans",Geneva,Verdana,sans-serif;
151+
font-weight: 400;
152+
font-style: normal;
153+
font-size: 20px;
154+
color: #fff;
155+
}
156+
143157
main {
144158
width: calc(100% - 270px);
145159
margin-left: 270px;
@@ -167,14 +181,19 @@ and (max-width : 1023px) {
167181
display: block;
168182
position: fixed;
169183
width: 100%;
170-
background-color: #ffc424;
184+
background-color: #f3bb22;
171185
padding-left: 5px;
172186
z-index: 10;
173187
}
174188

175189
nav {
176190
margin-top: 40px;
177-
display: none;
191+
transform: translateX(-100%);
192+
transition: transform .5s;
193+
}
194+
195+
nav.open {
196+
transform: translateX(0)
178197
}
179198

180199
main {

0 commit comments

Comments
 (0)