% @side_nav = "js" %>
Section 1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Section 2. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Sections replace a few things that you are used to from Foundation 3. We've taken the accordion, the tabs and the vertical nav and combined them into this really flexible plugin that can handle all of those. The single JS file handles all the interactions, but the classes you add to the element control how it gets rendered and styled across our breakpoint.
There are two ways to build sections in Foundation 4, with our predefined HTML classes or with our structure and mixins. Building a sections using our predefined classes is super-easy, you just need to create a <div class="section-container" data-section>
as a wrapper for the sections themselves. Inside of this wrapper, you'll create either a <section class="section">
or <div class="section">
. Within that you'll include some sort of .title
(this can be headers or a paragragh) and a <div class="content">
. Here is the markup you'll need:
If you want to use ZURB's default styles for section elements you can apply the auto
, tabs
, accordion
, vertical-nav
, or horizontal-nav
classes. By default, section elements will be an accordion on mobile and tabs on desktops and tablets. If you want to adjust this behavior and force a particular format for your section, you will need to set data-section
equal to the format you want to force as shown in the variations below.
This example will automatically switch between tabs and accordion based on the resolution of the device.
The class options:
For these styles to come across, make sure you have the default Foundation CSS package or that you've selected section from a custom package. These should be linked up following our default HTML page structure.
Adding an accordion
class to the section container will show an accordion on both small and large screens.
Adding a tabs
class to the section container will enable tabs on both small and large screens.
Adding a vertical-nav
class to the section container will enable vertical navigation elements on large screens and show an accordion on small screens.
Vertical navigation elements usually appear within the grid so the width can be controlled on desktop.
Use the side-nav
class on the list to apply the Foundation navigation styles
Content to the right of the navigation.
Adding a horizontal-nav
class to the section container will enable horizontal navigation elements on large screens and show an accordion on small screens.
Horizontal navigation is a combination of the tab setting with vertical navigation drop downs.
Use the side-nav
class on the list to apply the Foundation navigation styles
Set deep-linking
to true to enable deep linking to sections of content. Deep linking allows visitors to visit a predefined URL with a hash that points to a particular section of the content. Deep linking also requires a matching data-slug
on the content section that the hash should point to, without the pound (#) sign.
Note: The section
element can be replaced with a div.section
element if you do not want to use HTML5 elements.
Content of section 1.
Content of section 2.
Note: emCalc();
is a function we wrote to convert px
to em
.
You'll need to include zepto.js
and foundation.js
above the sections plugin. Above your closing </body>
tag include the following line of code and make sure you have the JS in your directory.
Read how to install Foundation JavaScript
Required Foundation Library: foundation.section.js
Then, you'll need to add a data-attribute to make the JS work properly on that element. That looks like:
<%= code_example ' ', :html %>You can either set these options in a data-options
attribute in the markup, data-options="option: value; option2: value syntax"
, or pass in on initialization.