First attempt at using a hamburger menu on mobile
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
a1ccc4bb2e
commit
55a840ae35
4 changed files with 113 additions and 4 deletions
|
@ -76,7 +76,7 @@ enableRobotsTXT = true
|
||||||
disable_share = true
|
disable_share = true
|
||||||
body_classes = "sans-serif bg-near-white"
|
body_classes = "sans-serif bg-near-white"
|
||||||
commentoEnable = true
|
commentoEnable = true
|
||||||
custom_css = ["css/isso.css", "css/leafbox.css", "css/baguetteBox.css"]
|
custom_css = ["css/isso.css", "css/baguetteBox.css", "css/hamburger.css"]
|
||||||
|
|
||||||
[privacy]
|
[privacy]
|
||||||
[privacy.googleAnalytics]
|
[privacy.googleAnalytics]
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
<nav class="pv3 ph3 ph4-ns {{ .Site.Params.navigation_dimming_class | default "bg-black-50" }}" role="navigation">
|
<nav class="pv3 ph3 ph4-ns {{ .Site.Params.navigation_dimming_class | default "bg-black-50" }}" role="navigation">
|
||||||
<div class="flex-l justify-between items-center center b">
|
<div class="flex-l justify-between items-center center b">
|
||||||
<a href="{{ .Site.Home.RelPermalink }}" class="f3 fw4 hover-white no-underline white-90 dib">
|
<a href="{{ .Site.Home.RelPermalink }}" class="site-logo f3 fw4 hover-white no-underline white-90 dib">
|
||||||
{{ with .Site.Params.site_logo }}
|
{{ with .Site.Params.site_logo }}
|
||||||
<img src="{{ . }}" class="w100 mw5-ns" alt="{{ $.Site.Title }}" />
|
<img src="{{ . }}" class="w100 mw5-ns" alt="{{ $.Site.Title }}" />
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ .Site.Title }}
|
{{ .Site.Title }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</a>
|
</a>
|
||||||
<div class="flex-l items-center">
|
<div class="main-menu-container flex-l items-center">
|
||||||
{{ partial "i18nlist.html" . }}
|
{{ partial "i18nlist.html" . }}
|
||||||
{{ if .Site.Menus.main }}
|
{{ if .Site.Menus.main }}
|
||||||
<ul class="pl0 mr3">
|
<input class="main-menu-button" type="checkbox" id="main-menu-button" />
|
||||||
|
<label class="main-menu-label" for="main-menu-button"><span class="main-menu-icon"></span></label>
|
||||||
|
<ul class="main-menu-list" class="pl0 mr3">
|
||||||
{{ range .Site.Menus.main }}
|
{{ range .Site.Menus.main }}
|
||||||
<li class="list f5 f4-ns fw4 dib pr3">
|
<li class="list f5 f4-ns fw4 dib pr3">
|
||||||
<a class="hover-white no-underline white-90 fw4" href="{{ .URL }}" title="{{ .Name }} page">
|
<a class="hover-white no-underline white-90 fw4" href="{{ .URL }}" title="{{ .Name }} page">
|
||||||
|
@ -20,7 +22,9 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</ul>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
<div class="top-social-container">
|
||||||
{{ partialCached "social-follow.html" . }}
|
{{ partialCached "social-follow.html" . }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
94
static/css/hamburger.css
Normal file
94
static/css/hamburger.css
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
.main-menu-button {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
|
||||||
|
/* hide social media links in mobile view */
|
||||||
|
|
||||||
|
.top-social-container {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
|
||||||
|
/* menu */
|
||||||
|
|
||||||
|
.main-menu-list {
|
||||||
|
clear: both;
|
||||||
|
max-height: 0;
|
||||||
|
transition: max-height 0.2s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* menu icon: middle bar */
|
||||||
|
|
||||||
|
.main-menu-icon,
|
||||||
|
.main-menu-icon:before,
|
||||||
|
.main-menu-icon:after {
|
||||||
|
background: lightblue;
|
||||||
|
display: block;
|
||||||
|
width: 30px;
|
||||||
|
content: '';
|
||||||
|
transition-duration: 0.2s;
|
||||||
|
transition-timing-function: ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-menu-icon {
|
||||||
|
height: 3px;
|
||||||
|
position: relative;
|
||||||
|
transition-property: background;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* menu icon: add one bar below and one above -> hamburger style */
|
||||||
|
|
||||||
|
.main-menu-icon:before,
|
||||||
|
.main-menu-icon:after {
|
||||||
|
height: 100%;
|
||||||
|
position: absolute;
|
||||||
|
transition-property: all;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-menu-icon:before { top: 10px; }
|
||||||
|
.main-menu-icon:after { top: -10px; }
|
||||||
|
|
||||||
|
/* limit the length of the menu item list */
|
||||||
|
|
||||||
|
.main-menu-button:checked ~ .main-menu-list {
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* parallel -> crossing transition of hamburger menu icon */
|
||||||
|
|
||||||
|
.main-menu-button:checked ~ .main-menu-label .main-menu-icon { background: transparent; }
|
||||||
|
.main-menu-button:checked ~ .main-menu-label .main-menu-icon:before { transform: rotate(-45deg); }
|
||||||
|
.main-menu-button:checked ~ .main-menu-label .main-menu-icon:after { transform: rotate(45deg); }
|
||||||
|
|
||||||
|
.main-menu-button:checked ~ .main-menu-label:not(.steps) .main-menu-icon:before,
|
||||||
|
.main-menu-button:checked ~ .main-menu-label:not(.steps) .main-menu-icon:after {
|
||||||
|
top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-menu-label {
|
||||||
|
display: inline-block;
|
||||||
|
cursor: pointer;
|
||||||
|
float: right;
|
||||||
|
padding: 28px 20px;
|
||||||
|
position: relative;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-menu-list {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-menu-list li {
|
||||||
|
display: block;
|
||||||
|
text-align: right;
|
||||||
|
padding: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reduce width of logo and place logo and hamburger menu on one line */
|
||||||
|
|
||||||
|
.site-logo { display: inline; }
|
||||||
|
.site-logo img { max-width: 70%; }
|
||||||
|
.main-menu-container { display: inline; }
|
||||||
|
}
|
|
@ -74,3 +74,14 @@
|
||||||
background-repeat:no-repeat;
|
background-repeat:no-repeat;
|
||||||
background-size:contain !important;
|
background-size:contain !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.menu {
|
||||||
|
min-height: 2.8rem; /* no way to control min height in Tachyons */
|
||||||
|
max-height: 0; /* hide menu completely when burger unchecked */
|
||||||
|
transition: max-height 0.5s; /* show/hide menu transition */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* when checkbox is checked, display menu (sibling element) */
|
||||||
|
#burger:checked ~ .menu {
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue