Commit 9814add5 authored by Hanna Schraffenberger's avatar Hanna Schraffenberger
Browse files

Menu responsive

parent fbcbe755
......@@ -6,13 +6,27 @@
</a>
</div>
<nav class="block-header-2--nav">
<nav class="block-header-2--nav" id="myTopnav">
<ul>
{% for nav_item in section.navigation %}
<li class="nav-item {% if page.url == nav_item.link %}active{% endif %}"><a href="{{ nav_item.link }}">{{ nav_item.link_text }}</a></li>
{% endfor %}
</ul>
<a href="javascript:void(0);" class="icon" onclick="toggleMenu()">
<i class="fa fa-bars"></i>
</a>
<a class="button primary small block-header-2--cta" href="{{ section.cta.url }}">{{ section.cta.button_text }}</a>
</nav>
</header>
\ No newline at end of file
</header>
<script>
function toggleMenu() {
var x = document.getElementById("myTopnav");
if (x.className === "block-header-2--nav") {
x.className += " responsive";
} else {
x.className = "block-header-2--nav";
}
}
</script>
\ No newline at end of file
......@@ -77,11 +77,36 @@ header {
max-width:320px
}
header {
background-color: #fff;
position: fixed;
top: 0;
width: 100%
}
}
/* Make menu look good on small screens , based on: https://www.w3schools.com/howto/howto_js_topnav_responsive.asp*/
/* When the screen is less than 600 pixels wide, hide all links, except for the first one ("Home"). Show the link that contains should open and close the topnav (.icon) */
@media screen and (max-width: 600px) {
.block-header-2--nav a:not(:first-child) {display: none;}
.block-header-2--nav a.icon {
float: right;
display: block;
}
}
/* The "responsive" class is added to the topnav with JavaScript when the user clicks on the icon. This class makes the topnav look good on small screens (display the links vertically instead of horizontally) */
@media screen and (max-width: 600px) {
.block-header-2--nav.responsive {position: relative;}
.block-header-2--nav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}
.block-header-2--nav.responsive a {
float: none;
display: block;
text-align: left;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment