?
This document uses PHP Chinese website manual Release
頂部導(dǎo)航欄放在頁面頭部:
<nav?class="top-bar"?data-topbar> ??<ul?class="title-area"> ????<li?class="name"> ??????<!--?如果你不需要標(biāo)題或圖標(biāo)可以刪掉它?--> ??????<h1><a?href="#">WebSiteName</a></h1> ????</li> ??????<!--?小屏幕上折疊按鈕:?去掉?.menu-icon?類,可以去除圖標(biāo)。? ??????如果需要只顯示圖片,可以刪除?"Menu"?文本?--> ????<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> <!--?初始化?Foundation?JS?--> <script> $(document).ready(function()?{ ????$(document).foundation(); }) </script>實例預(yù)覽 ?
使用 <nav class="top-bar" data-topbar>
創(chuàng)建標(biāo)準(zhǔn)工具條。.title-area
類定義了網(wǎng)站logo區(qū)域 (必須防止li.name
內(nèi)) 。屏幕變小后你就可以看到一個 ?"menu" 按鈕。 Foundation 的菜單會根據(jù)屏幕尺寸自動折疊喝延展:
小屏幕上,由于尺寸的原因很多選項會被隱藏。 li.toggle-topbar menu.icon
類創(chuàng)建了一個菜單的按鈕,點擊它可以顯示被隱藏的選項。
提示: 重置瀏覽器窗口查看效果。
.top-bar-section
定義了導(dǎo)航的鏈接部分。 .left
類指定鏈接左對齊。 ?.active
類用于顯示選中的項,背景為藍(lán)色。
提示: ?如果你想導(dǎo)航鏈接右對齊可以將 .left
修改為 .right
:
<section?class="top-bar-section"> ??<ul?class="right">...實例預(yù)覽 ?
你可以同時設(shè)置左邊對齊與右邊對齊:
<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> </section>實例預(yù)覽 ?
導(dǎo)航欄可以通過 .divider
類來添加分割線 (大屏幕上是垂直的線,小屏幕上是水平線):
<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> </ul>實例預(yù)覽 ?
頂部導(dǎo)航欄可以設(shè)置下拉菜單。
可以通過在 <li>
?元素上添加 .has-dropdown
類來設(shè)置下拉菜單:
<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> </section>實例預(yù)覽 ?
使用 .divider
類來設(shè)置下拉菜單的分割線:
<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> </ul>實例預(yù)覽 ?
在 <li>
內(nèi)添加 <label>
元素來設(shè)置下拉菜單的標(biāo)簽(標(biāo)題):
<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> </ul>實例預(yù)覽 ?
下拉菜單可以再嵌入一個下拉菜單:
?<section?class="top-bar-section"> ??<ul?class="left"> ????<li?class="has-dropdown"> ??????<a?href="#">Dropdown</a> ??????<ul?class="dropdown"> ????????<li><label>Level?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><label>Level?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><label>Level?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> </section>實例預(yù)覽 ?
默認(rèn)情況下導(dǎo)航欄的下拉菜單在鼠標(biāo)移動過去后顯示,我們可以使用 data-options="is_hover: false"
屬性來設(shè)置導(dǎo)航欄在鼠標(biāo)在點擊后顯示:
<nav?class="top-bar"?data-topbar?data-options="is_hover:?false">實例預(yù)覽 ?
你可以在導(dǎo)航欄上放置圖標(biāo)和按鈕:
<li><a?href="#"?class="button">Button?Link</a></li>實例預(yù)覽 ?
你可以在導(dǎo)航欄上放上圖標(biāo),更多圖片樣式可以查看Foundation 圖標(biāo)教程:
<head> <!--?Foundation?圖標(biāo)樣式?--> <link?rel="stylesheet"?> </head> <ul?class="left"> ??<li?class="active"><a?href="#"><i?class="fi-home"></i>?Home</a></li> ??<li><a?href="#"><i?class="fi-torso"></i>?Sign?Up</a></li> ??<li><a?href="#"><i?class="fi-magnifying-glass"></i>?Search</a></li>? </ul>實例預(yù)覽 ?
導(dǎo)航欄可以固定在頁面頂部。
頁面滾動時導(dǎo)航欄在頂部是不會動的。
要固定導(dǎo)航欄只需要將導(dǎo)航欄放在 <div class="fixed">
內(nèi)即可:
<div?class="fixed"> ??<nav?class="top-bar"?data-topbar> ????... ??</nav> </div>實例預(yù)覽 ?
我們可以將導(dǎo)航欄放在 <div class="sticky">
內(nèi)來設(shè)置導(dǎo)航欄的絕對定位,當(dāng)滾動條滾到到該區(qū)域時,該導(dǎo)航欄就像固定導(dǎo)航欄一樣在頂部不動:
<div?class="sticky"> ??<nav?class="top-bar"?data-topbar> ????... ??</nav> </div>實例預(yù)覽 ?
當(dāng)你使用 .sticky
類時,頂部導(dǎo)航欄在所有屏幕尺寸上將固定不動。如果你需要在指定屏幕上設(shè)定只需要在 <nav>
上添加 data-options="sticky_on: small|medium|large"
屬性即可:
<div?class="sticky"> ??<!--?只有在大屏幕上?--> ??<nav?class="top-bar"?data-topbar?data-options="sticky_on:?large"> ????.. ???</nav> </div>
或者通過數(shù)組設(shè)置多個屏幕尺寸:
<div?class="sticky"> ??<!--?小屏幕和大屏幕?(沒有中等屏幕)--> ??<nav?class="top-bar"?data-topbar?data-options="sticky_on:?[small,?large]"> ????.. ???</nav> </div>
關(guān)于我們 聯(lián)系我們 留言板
手冊網(wǎng)