Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Foundation off-canvas navigation on mobile only?

I am making an off-canvas navigation using Foundation, however, I only want the off-canvas nav to display on mobile devices, on desktop browsers I will use a standard navigation menu. My question is, can I reuse the code from my off-canvas nav for my desktop nav, or will I have to code 2 separate navigation menus?

Here is what my nav code looks like for the off-canvas nav:

<div class="off-canvas-wrap">
  <div class="inner-wrap">
    <nav class="tab-bar">
      <section class="left-small">
        <a class="left-off-canvas-toggle menu-icon" ><span></span></a>
      </section>
    </nav>

    <aside class="left-off-canvas-menu">
      <ul class="off-canvas-list">
        <li {% if page.slug == "index" %}class="active"{% endif %}>
          <a href="/">Home</a>
        </li>
        <li>{% nav site, no_wrapper: true %}</li>
      </ul>
    </aside>

<section class="main-section">
PAGE CONTENT HERE
</section>

<a class="exit-off-canvas"></a>

  </div>
</div>

Thanks in advance!

like image 336
user3101431 Avatar asked Jan 09 '14 20:01

user3101431


People also ask

How do I use off-canvas in Foundation?

Foundation off-canvas creates multiple menus on the left and right side. You can toggle the off-canvas by using the title bar on both left and right sides. Sets the left and right hand off canvas on larger and medium screens using .reveal-for-medium or .reveal-for-large classes.

What is off-canvas navigation?

Foundation's Off-canvas is a well established mobile pattern for navigation that can also be used to create a responsive sidebar. It can open from any direction, left, right, top, and bottom.

Are off-canvas layouts right for You?

Off-canvas layouts are common and useful for mobile and desktop layouts. Be a navigation guru with our Foundation online webinar training. You’ll learn techniques for creating responsive navigations that work with any type of site. In addition to that you can learn tips and tricks and best practices for all of Foundation’s components. Good news!

What is off-canvas menu?

This Off-canvas menu can open from left, right, top or bottom, overlap our content, push our content, and can work with sticky elements. These are responsive mobile patterns mainly for mobile screens.


1 Answers

You'll need to use separate sets of navigation in order to achieve what you're wanting, unfortunately. In order to use both, however, you'll need to structure your website to accommodate the off-canvas menu, but only call the off-canvas menu when you're on small menus. The menu that you'll use within the main part of the site (within the "main-section") will have to be hidden for small to avoid multiple menus showing.

We recently came across this issue with our corporate site and we only wanted to call the navigation once, however it was proving extremely difficult.

Here's a basic example of how the structure would look:

  <div class="off-canvas-wrap">
    <div class="inner-wrap">                

      <nav class="tab-bar show-for-small">
        <section class="left-small">
          <a class="left-off-canvas-toggle menu-icon" ><span></span></a>
         </section>

        <section class="middle tab-bar-section">
          <h1 class="title"><a href="/home"><img id="logoSmall" src="/images/main/header_logo_small.png" /></a></h1>
        </section>
      </nav>

      <aside class="left-off-canvas-menu">
        <ul class="off-canvas-list">
          <li><label>Menu</label></li>
          <li><a>link1</a></li>
          <li><a>link2</a></li>
          <li><a>link2</a></li>
        </ul>
      </aside>



      <section class="main-section">

        <!-- All of your website goes here -->
        <!-- Including the navigation you want to show on medium-and-up-->

      </section>

      <a class="exit-off-canvas"></a>
    </div><!--/innerWrapp-->
  </div><!--/offCanvasWrap-->
like image 184
Dylan Avatar answered Oct 10 '22 16:10

Dylan