CodePen

HTML

            
              <h1>Responsive menu using elementQuery</h1>
<p>Try changing the: viewport width, width of <code>nav.menu</code> elements, base font-size, or zoom.</p>
<p>The following <a href="https://github.com/tysonmatanich/elementQuery">elementQuery</a> breakpoints are set:</p>
<ul>
    <li><code>min-width: 25em /* 400px */</code></li>
</ul>

<div class="container" style="font-size: 1em;">
    <p>Menu in a container with <code>font-size: 1em</code></p>
    <nav class="menu">
        <ul>
            <li><a href="#one">One</a></li>
            <li><a href="#two">Two</a></li>
            <li><a href="#three">Three</a></li>
        </ul>
    </nav>
</div>
<div class="container" style="max-width: 19em;">
    <p>Menu in a container with <code>max-width: 19em</code></p>
    <nav class="menu">
        <ul>
            <li><a href="#one">One</a></li>
            <li><a href="#two">Two</a></li>
            <li><a href="#three">Three</a></li>
        </ul>
    </nav>
</div>
<div class="container" style="min-width: 25em;">
    <p>Menu in a container with <code>min-width: 25em</code></p>
    <nav class="menu">
        <ul>
            <li><a href="#one">One</a></li>
            <li><a href="#two">Two</a></li>
            <li><a href="#three">Three</a></li>
        </ul>
    </nav>
</div>
<div class="container" style="font-size: 2em;">
    <p>Menu in a container with <code>font-size: 2em</code></p>
    <nav class="menu">
        <ul>
            <li><a href="#one">One</a></li>
            <li><a href="#two">Two</a></li>
            <li><a href="#three">Three</a></li>
        </ul>
    </nav>
</div>
            
          
!
via HTML Inspector

CSS

            
              body {
    font-family: sans-serif;
}

.container {
    margin-top: 1em;
    border: 2px solid #ccc;
    border-radius: 0.25em;
    padding: 1em;
}

.menu {
    padding: 0 0.5em;
    background: #eee;
    border-radius: 0.25em;
}

.menu ul {
    margin: 0;
    padding: 0.125em 0;
    list-style: none;
}

.menu li {
    margin: 0.5em 0.125em;
    padding: 0.5em 1em;
    color: #fff;
    background-color: #0094ff;
    text-align: center;
    border-radius: 0.25em;
}

.menu[min-width~="25em"] li {
    display: inline-block;
    text-align: left;
    background-color: #74bd0a;
}

.menu a {
    color: #fff;
    text-decoration: none;
}
        
h1 {
    font-size: 1.25em;
}

p {
    margin: 0 0 1em;;
}

code {
    padding: 0.25em 0.5em;
    color: #000;
    background-color: #f9f9f9;
}

a {
    color: #3a97c4;
}
            
          
!
? ?
? ?
Must be a valid URL.
+ add another resource
via CSS Lint

JS

            
              
            
          
!
Must be a valid URL.
+ add another resource
via JS Hint
Loading ..................