5
<title>Example: Basic Top Nav</title>
6
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Maven+Pro:400,700">
7
<link rel="stylesheet" href="../../build/cssgrids/grids-min.css">
8
<link rel="stylesheet" href="../assets/css/main.css">
9
<link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
10
<script src="../../build/yui/yui-min.js"></script>
15
<h1>Example: Basic Top Nav</h1>
20
<div class="yui3-u-3-4">
22
<div class="content"><div class="intro">
24
This example demonstrates how to create a traditional, two-column page layout (<a href="../cssgrids/index.html">using Grids</a>) with top navigation featuring drop-down menus.
28
<div class="example newwindow">
29
<a href="node-menunav-2-example.html" target="_blank" class="button">
30
View Example in New Window
34
<h2>Setting Up the HTML</h2>
37
Begin by including the <a href="../cssgrids/index.html#dependencies">CSS Grids dependencies</a> and grid
38
markup (this example uses a 2 column version of the
39
<a href="../cssgrids/cssgrids-fluid.html">Fluid Page Template</a> with a 160px left column).
40
Add the markup for the menu to the left column of the grid, and the class <code>yui3-skin-sam</code>
41
to the <code><body></code>.
45
The root menu of menus built using the MenuNav Node Plugin can have a verical or horizontal
46
orientation. The default orientation for menus is vertical, but can be easily switched to
47
horizontal by applying a class of <code>yui3-menu-horizontal</code> to the node representing the
48
root menu's bounding box, as illustrated below:
51
<pre class="code prettyprint"><div id="productsandservices" class="yui3-menu yui3-menu-horizontal"><!-- Bounding box -->
52
<div class="yui3-menu-content"><!-- Content box -->
54
<!-- Menu items -->
57
</div></pre>
61
<h2>Initializing the Menu</h2>
63
With the menu markup in place, retrieve the Node instance representing the root
64
menu (<code><div id="productsandservices"></code>) and call the
65
<a href="http://yuilibrary.com/yui/docs/api/classes/Node.html#method_plug"><code>plug</code></a>
66
passing in a reference to the MenuNav Node Plugin.
69
<pre class="code prettyprint">// Call the "use" method, passing in "node-menunav". This will load the
70
// script and CSS for the MenuNav Node Plugin and all of the required
71
// dependencies.
73
YUI().use('node-menunav', function(Y) {
75
// Retrieve the Node instance representing the root menu
76
// (<div id="productsandservices">) and call the "plug" method
77
// passing in a reference to the MenuNav Node Plugin.
79
var menu = Y.one("#productsandservices");
81
menu.plug(Y.Plugin.NodeMenuNav);
87
<em>Note:</em> In keeping with the
88
<a href="http://developer.yahoo.com/performance/">Exceptional Performance</a>
89
team's recommendation, the script block used to instantiate the menu will be
90
<a href="http://developer.yahoo.com/performance/rules.html#js_bottom">placed at the bottom of the page</a>.
91
This not only improves performance, it helps ensure that the DOM subtree of the
92
element representing the root menu
93
(<code><div id="productsandservices"></code>) is ready to be scripted.
99
<div class="yui3-u-1-4">
100
<div class="sidebar">
104
<div class="sidebox">
106
<h2 class="no-toc">Examples</h2>
110
<ul class="examples">
113
<li data-description="Creating left navigation using the MenuNav Node Plugin.">
114
<a href="menunav-leftnav.html">Basic Left Nav</a>
119
<li data-description="Creating top navigation using the MenuNav Node Plugin">
120
<a href="node-menunav-2.html">Basic Top Nav</a>
125
<li data-description="Creating menu button navigation using the MenuNav Node Plugin">
126
<a href="node-menunav-3.html">Menu Button Top Nav</a>
131
<li data-description="Creating split button navigation using the MenuNav Node Plugin">
132
<a href="node-menunav-4.html">Split Button Top Nav</a>
137
<li data-description="Adding shadows to submenus of a left nav using the MenuNav Node Plugin">
138
<a href="node-menunav-5.html">Left Nav with Submenus with Shadows</a>
143
<li data-description="Adding rounded corners to submenus of a left nav using the MenuNav Node Plugin">
144
<a href="node-menunav-6.html">Left Nav With Submenus With Rounded Corners</a>
149
<li data-description="Skining a menu built using the MenuNav Node Plugin to look like the menus on Flickr">
150
<a href="node-menunav-7.html">Skinning Menus Created Using the MenuNav Node Plugin</a>
165
<script src="../assets/vendor/prettify/prettify-min.js"></script>
166
<script>prettyPrint();</script>