Foundation Top Bar
The top bar is placed at the head of the page:
Example
<
nav
class=
"top-bar"
data-topbar
<
ul
class=
"title-area"
<
li
class=
"name"
<
h1
<
a
href=
"#"
WebSiteName
<
/a
<
/h1
<
/li
<
li
class="toggle-topbar menu-icon"
<
a
href=
"#"
<
span
Menu
<
/span
<
/a
<
/li
<
/ul
<
section
class=
"top-bar-section"
<
ul
class=
"left"
<
li
class=
"active"
<
a
href=
"#"
Home
<
/a
<
/li
<
li
<
a
href=
"#"Page 1
<
/a
<
/li
<
li
<
a
href=
"#"Page 2
<
/a
<
/li
<
li
<
a
href=
"#"Page 3
<
/a
<
/li
<
/ul
<
/section
<
/nav
<
script$(document).ready(function() {
$(document).foundation();
})
<
/script
Try it »
Example Parsing
Use Create a standard toolbar. .title-area class defines the site logo area (must be placed li.name inside). When the screen becomes smaller you will see a "menu" button. Foundation's menu automatically collapses and expands based on screen size:
On small screens, many options are hidden due to the limited size. li.toggle-topbar menu.icon class creates a menu button; clicking it displays the hidden options.
Tip: Resize the browser window to see the effect.
.top-bar-section defines the links section of the navigation. .left class specifies left-aligned links. .active class is used to show the selected item, with a blue background.
Tip: If you want the navigation links right-aligned, you can .left to .right :
Example
<
section
class=
"top-bar-section"
<
ul
class=
"right"...
Try it »
You can set both left and right alignment at the same time:
Example
<
section
class=
"top-bar-section"
<
ul
class=
"left"
<
li
class=
"active"
<
a
href=
"#"
Home
<
/a
<
/li
<
li
<
a
href=
"#"Page 1
<
/a
<
/li
<
li
<
a
href=
"#"Page 2
<
/a
<
/li
<
/ul
<
ul
class=
"right"
<
li
<
a
href=
"#"Sign Up
<
/a
<
/li
<
li
<
a
href=
"#"
Login
<
/a
<
/li
<
/ul
<
/sectionTry it »
The navigation bar can use .divider class to add dividers (vertical lines on large screens, horizontal lines on small screens):
Example
<
ul
class=
"left"
<
li
class=
"active"
<
a
href=
"#"
Home
<
/a
<
/li
<
li
class=
"divider"
<
/li
<
li
<
a
href=
"#"Page 1
<
/a
<
/li
<
li
class=
"divider"
<
/li
<
li
<
a
href=
"#"Page 2
<
/a
<
/li
<
li
class=
"divider"
<
/li
<
li
<
a
href=
"#"Page 3
<
/a
<
/li
<
li
class=
"divider"
<
/li
<
/ulTry it »
Dropdown menus in the navigation bar
The top bar can have dropdown menus.
You can set this by element, add the .has-dropdown class to set up a dropdown menu:
Example
<
section
class=
"top-bar-section"
<
ul
class=
"left"
<
li
class=
"active"
<
a
href=
"#"
Home
<
/a
<
/li
<
li
class=
"has-dropdown"
<
a
href=
"#"
Dropdown
<
/a
<
ul
class=
"dropdown"
<
li
<
a
href=
"#"First link in dropdown
<
/a
<
/li
<
li
<
a
href=
"#"Second link in dropdown
<
/a
<
/li
<
li
class=
"active"
<
a
href=
"#"Active link in dropdown
<
/a
<
/li
<
/ul
<
/li
<
/ul
<
/sectionTry it »
Horizontal rule
Use .divider class to set the dropdown menu's divider:
Example
<
ul
class=
"dropdown"
<
li
<
a
href=
"#"
Apple
<
/a
<
/li
<
li
<
a
href=
"#"
Banana
<
/a
<
/li
<
li
<
a
href=
"#"
Orange
<
/a
<
/li
<
li
class=
"divider"
<
/li
<
li
<
a
href=
"#"
Kale
<
/a
<
/li
<
li
<
a
href=
"#"
Spinach
<
/a
<
/li
<
/ulTry it »
Dropdown menu labels
in add a element inside to set the dropdown menu's label (title):
Example
<
ul
class=
"dropdown"
<
li
<
label
Fruit
<
/label
<
/li
<
li
<
a
href=
"#"
Apple
<
/a
<
/li
<
li
<
a
href=
"#"
Banana
<
/a
<
/li
<
li
<
a
href=
"#"
Orange
<
/a
<
/li
<
li
class=
"divider"
<
/li
<
li
<
label
Vegetable
<
/label
<
/li
<
li
<
a
href=
"#"
Kale
<
/a
<
/li
<
li
<
a
href=
"#"
Spinach
<
/a
<
/li
<
/ulTry it »
Nested dropdown menus
A dropdown menu can have another dropdown menu nested inside:
Example
<
section
class=
"top-bar-section"
<
ul
class=
"left"
<
li
class=
"has-dropdown"
<
a
href=
"#"
Dropdown
<
/a
<
ul
class=
"dropdown"
<
li
<
labelLevel 1
<
/label
<
/li
<
li
<
a
href=
"#"
Link
<
/a
<
/li
<
li
<
a
href=
"#"
Link
<
/a
<
/li
<
li
class=
"has-dropdown"
<
a
href=
"#"New dropdown
<
/a
<
ul
class=
"dropdown"
<
li
<
labelLevel 2
<
/label
<
/li
<
li
<
a
href=
"#"2nd level dropdown
<
/a
<
/li
<
li
<
a
href=
"#"2nd level dropdown
<
/a
<
/li
<
li
class=
"has-dropdown"
<
a
href=
"#"New dropdown
<
/a
<
ul
class=
"dropdown"
<
li
<
labelLevel 3
<
/label
<
/li
<
li
<
a
href=
"#"3rd level dropdown
<
/a
<
/li
<
li
<
a
href=
"#"3rd level dropdown
<
/a
<
/li
<
/ul
<
/li
<
/ul
<
/li
<
/ul
<
/li
<
/ul
<
/sectionTry it »
Clickable
By default, the navigation bar's dropdown menu appears when the mouse moves over it; we can use data-options="is_hover: false" attribute to make the navigation bar appear on mouse click:
Example
<
nav
class=
"top-bar"data-topbar data-options=
"is_hover: false"
Try it »
Buttons and icons on the navigation bar
You can place icons and buttons on the navigation bar:
Example
<
li
<
a
href=
"#"
class=
"button"Button Link
<
/a
<
/liTry it »
You can place icons on the navigation bar; for more icon styles, see Foundation Icons Tutorial:
Example
<
head
<
ul
class=
"left"
<
li
class=
"active"
<
a
href=
"#"
<
i
class=
"fi-home"
<
/i
Home
<
/a
<
/li
<
li
<
a
href=
"#"
<
i
class=
"fi-torso"
<
/iSign Up
<
/a
<
/li
<
li
<
a
href=
"#"
<
i
class=
"fi-magnifying-glass"
<
/i
Search
<
/a
<
/li
<
/ulTry it »
Fixed navigation bar
The navigation bar can be fixed at the top of the page.
When the page scrolls, the navigation bar stays fixed at the top.
To fix the navigation bar, simply place it inside ... Try it » We can place the navigation bar inside ... Try it » When you use data-topbar data-options= "sticky_on: large" .. Or set multiple screen sizes through an array: data-topbar data-options= "sticky_on: [small, large]" .. Example
<
div
class=
"fixed"
<
nav
class=
"top-bar"
data-topbar<
/nav
<
/div
Absolute positioning of the navigation bar
Example
<
div
class=
"sticky"
<
nav
class=
"top-bar"
data-topbar<
/nav
<
/div.sticky class, the top bar stays fixed on all screen sizes. If you need to set it on specific screens, you only need to on the element, add data-options="sticky_on: small|medium|large" attribute:Example
<
div
class=
"sticky"
<
nav
class=
"top-bar"<
/nav
<
/divExample
<
div
class=
"sticky"
<
nav
class=
"top-bar"<
/nav
<
/div