Skip to content

Commit 376ba50

Browse files
committed
Add markup and style for a mobile friendly hamburger button menu
The markup is added before the actual archnavbarlist to make it possible to select said list via the CSS sibling selector depending on hamburger state/class. Note that this commit removes the minium body width of 650px.
1 parent 9bddc5d commit 376ba50

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

sitestatic/archweb.css

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,60 @@
3434
#archnavbarlist li a { color: #999; font-weight: bold !important; text-decoration: none !important; }
3535
#archnavbarlist li a:hover { color: white !important; text-decoration: underline !important; }
3636

37+
/* style the navbar for mobile viewport */
38+
@media (max-width: 768px) {
39+
/* style hamburger icon */
40+
#hamburger {
41+
width: 50px;
42+
height: 30px;
43+
display: none;
44+
margin-left: auto;
45+
}
46+
47+
#hamburger span {
48+
background-color: #fff;
49+
border-radius: 8px;
50+
height: 3px;
51+
width: 40px;
52+
display: block;
53+
margin: 5px;
54+
transition: 0.5s;
55+
}
56+
57+
/* animate hamburger */
58+
#hamburger.open span:nth-child(1) { transform: rotate(45deg) translateY(10px); }
59+
#hamburger.open span:nth-child(2) { opacity: 0; }
60+
#hamburger.open span:nth-child(3) { transform: rotate(-45deg) translateY(-10px); }
61+
62+
/* display nav items in hamburger menu fashion */
63+
.open + #archnavbarmenu #archnavbarlist {
64+
display: flex !important;
65+
flex-direction: column;
66+
align-items: flex-start;
67+
padding-bottom: 20px !important;
68+
width: 100%;
69+
position: absolute;
70+
left: 0;
71+
top: 60px;
72+
background-color: #333;
73+
}
74+
75+
#archnavbar {
76+
display: flex;
77+
align-items: center;
78+
position: relative;
79+
}
80+
81+
#hamburger {
82+
display: block;
83+
}
84+
85+
#archnavbarlist {
86+
display: none !important;
87+
position: relative;
88+
}
89+
}
90+
3791
/* END ARCH GLOBAL NAVBAR */
3892

3993
/* simple reset */
@@ -45,7 +99,6 @@
4599

46100
/* general styling */
47101
body {
48-
min-width: 650px;
49102
background: #f6f9fc;
50103
color: #222;
51104
font: normal 100% sans-serif;

templates/base.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
<body class="{% if user.is_authenticated %}devmode {% endif %}{% block bodyclass %}{% endblock %}">
1919
<div id="archnavbar" class="{% block navbarclass %}anb-home{% endblock %}">
2020
<div id="archnavbarlogo"><h1><a href="/" title="Return to the main page">Arch Linux</a></h1></div>
21+
<div id="hamburger">
22+
<span></span>
23+
<span></span>
24+
<span></span>
25+
</div>
2126
<div id="archnavbarmenu">
2227
<ul id="archnavbarlist">
2328
<li id="anb-home"><a href="/" title="Arch news, packages, projects and more">Home</a></li>

0 commit comments

Comments
 (0)