Bootstrap Navigation

23
Bootstrap Navigation Easy and good-looking navigation tabs and bars

Transcript of Bootstrap Navigation

Page 1: Bootstrap Navigation

Bootstrap Navigation Easy and good-looking navigation tabs and bars

Page 2: Bootstrap Navigation

Let's talk about ...

� Dropdown and dropup menus � Tabs � Pills � Navbars

Page 3: Bootstrap Navigation

Remember, thinking in Bootstrap means content first, styling second

�  For all of these components, you should start with the structure and the content

� Then you'll apply classes

3

Page 4: Bootstrap Navigation

DROPDOWN MENUS

Page 5: Bootstrap Navigation

<button>

News Team

</button>

<ul>

<li><a href="Anchor">Ron Burgundy</a></li>

<li><a href="coAnchor">Veronica Corningstone</a</li>

<li><a href="Weather">Brick Tamland</a></li>

<li><a href="Sports">Champ Kind</a></li>

<li><a href="Features">Brian Fantana</a></li>

</ul>

A dropdown requires ... ... something to

click ... ... and some things

to show/hide.

Page 6: Bootstrap Navigation

<button class="btn btn-default" data-toggle="dropdown">

News Team <span class="caret"></span>

</button>

<ul class="dropdown-menu">

<li><a href="Anchor">Ron Burgundy</a></li>

<li><a href="coAnchor">Veronica Corningstone</a</li>

<li><a href="Weather">Brick Tamland</a></li>

<li><a href="Sports">Champ Kind</a></li>

<li><a href="Features">Brian Fantana</a></li>

</ul>

After adding attributes ...

Page 7: Bootstrap Navigation

To make a dropup menu � Wrap it in a div class="dropup"<div class="dropup"> <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"> News Team <span class="caret"></span> </button> <ul class="dropdown-menu"> <li> <a href="Anchor">Ron Burgundy</a> </li> ... </ul></div>

Page 8: Bootstrap Navigation

TABS

Page 9: Bootstrap Navigation

Tabbed Browsing - Content <ul>

<li><a href="home">KQHS Channel 9</a></li>

<li><a href="mantooth">Wes Mantooth</a></li>

<li><a href="baxter">Baxter's Bites</a></li>

<li><a href="news">San Diego News</a></li>

</ul>

� This will allow the user to click on a tab and visit that page

� But they don't look like tabs yet

9

Page 10: Bootstrap Navigation

Tabbed Browsing - Styling

<ul class="nav nav-tabs">

<li><a href="home">KQHS Channel 9</a></li>

<li><a href="mantooth">Wes Mantooth</a></li>

<li class="active">

<a href="baxter">Baxter's Bites</a></li>

<li><a href="news">San Diego News</a></li>

</ul>

10

Page 11: Bootstrap Navigation

That's great for multiple pages, but what about SPAs? �  For a single page application (SPA), change the

links to internal anchors and put the target content in <div>s

� Then we let Bootstap hide and show the divs as needed

� Like so ...

11

Page 12: Bootstrap Navigation

Tabbed Sections In The Same Document 1.  Put your "pages" (aka "panes") in <div>s 2.  Enclose those in a bigger <div> 3.  Enclose them and your tabs in an even bigger <div> <div> <!– The enclosing div --> <ul class="nav nav-tabs"> <li><a href="#home">KQHS Channel 9</a></li> <li><a href="#wes">Wes Mantooth</a></li> <li><a href="#baxter">Baxter's Bites</a></li> <li><a href="#news">San Diego News</a></li> </ul> <div> <!– All the panes --> <div id="home"><p>Stuff about KQHS here</p></div> <div id="wes"><p>Stuff about Wes here</p></div> <div id="baxter"><p>Stuff about Baxter</p></div> <div id="news"><p>Stuff about News here</p></div> </div> </div>

12

Page 13: Bootstrap Navigation

Tabbed Sections In Same Document - Styling <div class="tabbable"> <ul class="nav nav-tabs"> <li><a href="#home" data-toggle="tab">KQHS Channel 9</a></li> <li><a href="#wes" data-toggle="tab">Wes Mantooth</a></li> <li><a href="#baxter" data-toggle="tab">Baxter's Bites</a></li> <li><a href="#news" data-toggle="tab">San Diego News</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane"><p>Stuff about KQHS here</p></div> <div id="wes" class="tab-pane"><p>Stuff about Wes here</p></div> <div id="baxter" class="tab-pane"><p>Stuff about Baxter</p></div> <div id="news" class="tab-pane"><p>Stuff about News here</p></div> </div></div>

Page 14: Bootstrap Navigation

PILLS

Page 15: Bootstrap Navigation

Pills are an attractive navigation option

(The glyphs are optional)

Page 16: Bootstrap Navigation

Pills are made exactly like tabs <ul class="nav nav-pills"> <li><a href="home">KQHS Channel 9</a></li> <li><a href="mantooth">Mantooth</a></li> <li class="active"> <a href="baxter">Baxter's Bites</a></li> <li><a href="news">San Diego News</a></li></ul>

Page 17: Bootstrap Navigation

NAVIGATION BARS

Page 18: Bootstrap Navigation

The Goal

� We want to create something like this:

18

Page 19: Bootstrap Navigation

Remember, start with the content <div>

<ul>

<li><a href="Home">KVWN Channel 4</a></li>

<li><a href="Schedule">Schedule</a></li>

<li><a href="#">News Team</a></li>

<li><a href="Visit">San Diego Sites</a></li>

</ul>

<form>

<input type="text" placeholder="Search">

<button type="submit">Search</button>

</form>

</div>

Page 20: Bootstrap Navigation

Then add classes so it will behave <div>

<ul class="nav navbar-nav">

<li><a href="Home">KVWN Channel 4</a></li>

<li><a href="Schedule">Schedule</a></li>

<li><a href="#">News Team</a></li>

<li><a href="Visit">San Diego Sites</a></li>

</ul>

<form class="navbar-form navbar-right">

<input type="text" placeholder="Search">

<button type="submit">Search</button>

</form>

</div>

Page 21: Bootstrap Navigation

To create submenus add a nested <ul> ...

<div> <ul class="nav navbar-nav"> <li><a href="Home">KVWN Channel 4</a></li>

<li><a href="Schedule">Schedule</a></li> <li> <a href="#">News Team</a> <ul> <li><a href="Anchor">Ron Burgundy</a></li> <li><a href="coAnchor">Veronica Corningstone</a></li>

<li><a href="Weather">Brick Tamland</a></li> <li><a href="Sports">Champ Kind</a></li> <li><a href="Features">Brian Fantana</a></li> </ul> </li> <li><a href="Visit">San Diego Sites</a></li>

</ul> ... </div>

Page 22: Bootstrap Navigation

... and assign it certain classes <div> <ul class="nav navbar-nav"> <li><a href="Home">KVWN Channel 4</a></li>

<li><a href="Schedule">Schedule</a></li> <li> <a href="#" data-toggle="dropdown">News Team</a> <ul class="dropdown-menu"> <li><a href="Anchor">Ron Burgundy</a></li> <li><a href="coAnchor">Veronica Corningstone</a></li>

<li><a href="Weather">Brick Tamland</a></li> <li><a href="Sports">Champ Kind</a></li> <li><a href="Features">Brian Fantana</a></li> </ul> </li> <li><a href="Visit">San Diego Sites</a></li>

</ul> ... </div>

Page 23: Bootstrap Navigation

tl;dr Bootstrap allows you to easily create navigation

affordances like: � Tabs � Pills � Dropdown menus � Responsive navbars