Skip to content

Instantly share code, notes, and snippets.

@danvk
Created September 19, 2014 18:35
Show Gist options
  • Save danvk/f935c892832a831c8006 to your computer and use it in GitHub Desktop.
Save danvk/f935c892832a831c8006 to your computer and use it in GitHub Desktop.
nav.navigation {
font-size: 12px;
position: absolute;
top: 0; left: 0; right: 0;
background: #fefefe;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
nav.navigation ul {
margin: 0;
padding: 0;
display: inline;
}
nav.navigation li {
display: inline-block;
}
nav.navigation a {
color: black;
text-decoration: none;
padding: 2px 11px;
}
nav.navigation li:hover a.unstyled {
visibility: hidden;
}
nav.navigation li:hover a.spacer {
visibility: visible;
}
nav.navigation .active {
font-weight: bold;
}
nav.navigation .spacer {
visibility: hidden;
font-weight: bold;
position: absolute;
margin-top: -2px;
}
{! Nav links have both an <a> and a hidden <span> to avoid layout shifts
on hover. !}
{% macro spacedLink(url, text) -%}
<a href="{{url}}" class="spacer">{{text}}</a>
<a href="{{url}}" class="unstyled">{{text}}</a>
{%- endmacro %}
{% macro nav(active) -%}
<nav class="navigation">
<ul>
<li class="{{ 'active' if active == 'home' else '' }}">
{{ spacedLink('/', 'Home') }}
</li>
<li class="{{ 'active' if active == 'runs' else '' }}">
{{ spacedLink('/runs', 'Runs') }}
{% if active == 'examine' %} &raquo;
<span class="{{ 'active' if active == 'examine' else '' }}">Examine</span>
{% endif %}
</li>
<li class="{{ 'active' if active == 'callers' else '' }}">
{{ spacedLink('/callers', 'Callers') }}
</li>
</ul>
</nav>
{%- endmacro %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment