jquery-mobile/docs/toolbars/docs-navbar.html
2010-11-11 14:15:42 -05:00

202 lines
No EOL
7.8 KiB
HTML
Executable file

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>jQuery Mobile Docs - Toolbars</title>
<link rel="stylesheet" href="../../themes/default" />
<link rel="stylesheet" href="../_assets/css/jqm-docs.css"/>
<script type="text/javascript" src="../../js/"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Navbar</h1>
</div><!-- /header -->
<div data-role="content">
<h2>Simple navbar</h2>
<p>jQuery Mobile has a very basic navbar widget that is useful for providing up to 5 buttons with optional icons in a bar , typically within a header or footer. </p>
<p>A navbar is coded as an unordered list of links wrapped in a container element that has the <code>data-role="navbar"</code> attribute. To set one of links to the active (selected) state, add <code>class="ui-btn-active"</code> to the anchor. In this example, we have a two-button navbar in the footer with the "One" item set to active:</p>
<pre><code>
&lt;div data-role=&quot;footer&quot;&gt;
&lt;div data-role=&quot;navbar&quot;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;a.html&quot; class=&quot;ui-btn-active&quot;&gt;One&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;b.html&quot;&gt;Two&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;!-- /navbar --&gt;
&lt;/div&gt;&lt;!-- /footer --&gt;
</code></pre>
<p>The navbar items are set to divide the space evenly so in this case, each button is 1/2 the width of the browser window:</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#"class="ui-btn-active">One</a></li>
<li><a href="#">Two</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<p>Adding a third item will automatically make each button 1/3 the width of the browser window:</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#" class="ui-btn-active">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<p>Adding a fourth more item will automatically make each button 1/4 the width of the browser window:</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#" class="ui-btn-active">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
<li><a href="#">Four</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<p>The navbar maxes out with 5 items, each 1/5 the width of the browser window:</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#" class="ui-btn-active">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
<li><a href="#">Four</a></li>
<li><a href="#">Five</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<p>If more than 5 items are added, the navbar will simply wrap to multiple lines:</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#" class="ui-btn-active">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
<li><a href="#">Four</a></li>
<li><a href="#">Five</a></li>
<li><a href="#">Six</a></li>
<li><a href="#">Seven</a></li>
<li><a href="#">Eight</a></li>
<li><a href="#">Nine</a></li>
<li><a href="#">Ten</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<h2>Navbars in headers</h2>
<p>If you want to add a navbar to the top of the page, you can still have a page title and buttons. Just add the navbar container inside the header block, right after the title and buttons in the source order.</p>
<div data-role="header">
<h1>I'm a header</h1>
<a href="index.html" data-icon="gear" class="ui-btn-right">Options</a>
<div data-role="navbar">
<ul>
<li><a href="#">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /header -->
<h2>Icons in navbars</h2>
<p>Icons can be added to navbar items by adding the <code>data-icon</code> attribute specifying a <a href="../buttons/buttons-icons.html">standard mobile icon</a> to each anchor.</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#" data-icon="grid">Summary</a></li>
<li><a href="#" data-icon="star" class="ui-btn-active">Favs</a></li>
<li><a href="#" data-icon="gear">Setup</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<p>Icons can be stacked above the labels by adding the <code>data-iconpos="top"</code> attribute to each anchor.</p>
<div data-role="footer">
<div data-role="navbar">
<ul>
<li><a href="#" data-icon="grid" data-iconpos="top">Summary</a></li>
<li><a href="#" data-icon="star" class="ui-btn-active" data-iconpos="top">Favs</a></li>
<li><a href="#" data-icon="gear" data-iconpos="top">Setup</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
<h2>Using 3rd party icon sets</h2>
<p>You can add any of the popular icon libraries like <a href="http://glyphish.com/">Glyphish</a> to achieve the iOS style tab tab that has large icons stacked on top of text labels. All that is required is a bit of custom styles to link to the icons and position them in the navbar. Here is an example using Glyphish icons and custom styles (view page source for styles) in our navbar:</p>
<style type="text/css">
.nav-glyphish-example .ui-btn .ui-btn-inner { padding-top: 40px !important; }
.ui-navbar-expanded ul .ui-btn .ui-btn-inner { padding-top: 55px !important; }
.nav-glyphish-example .ui-btn .ui-icon, .ui-navbar-expanded ul .ui-btn .ui-icon { width: 30px!important; height: 30px!important; margin-left: -15px !important; box-shadow: none!important; -moz-box-shadow: none!important; -webkit-box-shadow: none!important; -webkit-border-radius: none !important; border-radius: none !important; }
.ui-navbar-expanded ul .ui-btn .ui-icon { top: 20px; }
#chat .ui-icon { background: url(glyphish-icons/09-chat2.png) 50% 50% no-repeat; }
#email .ui-icon { background: url(glyphish-icons/18-envelope.png) 50% 50% no-repeat; }
.nav-glyphish-example .ui-navbar-toggle .ui-icon { background: url(glyphish-icons/19-gear.png) 50% 50% no-repeat !important; }
#login .ui-icon { background: url(glyphish-icons/30-key.png) 50% 50% no-repeat; }
#beer .ui-icon { background: url(glyphish-icons/88-beermug.png) 50% 50% no-repeat; }
#coffee .ui-icon { background: url(glyphish-icons/100-coffee.png) 50% 50% no-repeat; }
#skull .ui-icon { background: url(glyphish-icons/21-skull.png) 50% 50% no-repeat; }
</style>
<div data-role="footer" class="nav-glyphish-example">
<div data-role="navbar" class="nav-glyphish-example">
<ul>
<li><a href="#" id="chat" data-icon="custom">Chat</a></li>
<li><a href="#" id="email" data-icon="custom">Email</a></li>
<li><a href="#" id="skull" data-icon="custom">Danger</a></li>
<li><a href="#" id="beer" data-icon="custom">Beer</a></li>
<li><a href="#" id="coffee" data-icon="custom">Coffee</a></li>
</ul>
</div>
</div>
<p>Icons by Joseph Wain / <a href="http://glyphish.com/">glyphish.com</a>. Licensed under the <a href="http://creativecommons.org/licenses/by/3.0/us/">Creative Commons Attribution 3.0 United States License</a>.</p>
<h2>Theming navbars</h2>
<p>Navbars can be set to any theme color by <code>data-theme</code> attribute to the links and specifying any theme swatch.</p>
<div data-role="footer">
<div data-role="navbar" data-theme="e">
<ul>
<li><a href="#" data-icon="grid" data-iconpos="top" data-theme="b">Summary</a></li>
<li><a href="#" data-icon="star" class="ui-btn-active" data-iconpos="top" data-theme="b">Favs</a></li>
<li><a href="#" data-icon="gear" data-iconpos="top" data-theme="b">Setup</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /footer -->
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>