Esempio menù verticale in una pagina web
di Lino Bertuzzi - Dicembre 2012

Main elements - Write a menu - Practical trick
 

 

To build a vertical menu you need two main elements tobe included or linked to an HTML page, which are :

  • a javascript file I called SpryMenuV.js . This file provides the operation of the vertical menu and disappearing submenu items. You can download this file by clicking on the link with the right button and choose "save as." Save it in a directory where he can easily find and retrieve. This file is placed in the web page between tags <head> ....</head> with the following statement:

    <script src="../scripts/SpryMenuBarV.js" type="text/javascript"></script>

  • be aware to link the correct directory. A CSS style sheet that I called SpMenubarV. css This CSS file defines the visual characteristics of the menu. You can download it by clicking on the link with the right button and choose "save as" and save it in a directory where you can then find easily. This file is placed in the web page -  be careful to set the right directory - with the statement

    <link href="SpMenuBarV.css" rel="stylesheet" type="text/css" />

Both files are quite long, should explain well use only the file you need to edit to change the appearance menu, ie the CSS file (style sheet, because that other one should not be changed and does not need explanations.
In case you need to remind you what are the directory, how to use them, and how to structure a site, I recommend going first to see the page of explanations (click).

Another necessary element is obviously the menu, that is, you must have already defined what is the list of menu items and submenu of each item with links to the files to be opened.. On the page of our example we can put this scheme with the menu their titles, again as an example, which then everyone will be able to change:

Soups > Pastas   Minestre    
Meat > Chicken   Beef    
Seafood > Blue   White   Shells
Raw vegetables            
Cooked vegetables            
Drink > with gas   wines   beer
 

WRITE A VERTICAL MENU

The menu is written as 'unordered list' with the following elements

<ul> which are the initials of 'unordered list' which is the beginning of the list, and </ ul> indicating the end of the list.The class is "MenubarVertical"

<li> they are the first two letters of the element 'list' and indicate the start of a line of the list and </ li>, which indicates the end of the line in the list

To start a sub open a line <li> with MenuBarItemSubmenu class "followed by a sub-list <ul> with many rows <li> ........ </ li > how many are the submenu items. To the ends of the sub-list is closed with </ ul>

You must attribute the menu class. The menu class is called MenuBarVertical and its properties can be found in the style sheet SpMenuBarV.css . So we have the following instructions, with reference to the above menu :

 <ul id="MenuBar1" class="MenuBarVertical" >
<li><a href="intro_soups.htm" target="mainFrame" class="MenuBarItemSubmenu" accesskey="I"><u>I</u>ntroduction</a>

<ul>
<li><a href="soups.htm" target="mainFrame" style="width:inherit;">Pastas</a></li>
<li><a href="minestre.htm" target="mainframe" style=width:inherit;">Minestre</a></li>
</ul>

</li>

<li><a href="intro_meat.htm" target="mainFrame" class="MenuBarItemSubmenu" accesskey="C"><u>M</u>eats</a>


<ul>
<li><a href="chicken.htm" target="mainFrame" style="width:inherit;">Pollo</a></li>
<li><a href="Beef.htm" target="mainFrame" style="width:inherit;">Manzo</a></li>
</ul>

</li>

<li><a href="intro_seafood.htm" target="mainFrame" class="MenuBarItemSubmenu" style="width:inherit;" accesskey="S"><u>S</u>eafood</a></li>

<ul>
<li><a href="blue.htm" target="mainFrame" style="width:inherit;">Blue</a></li>
<li><a href="white.htm" target="mainframe" style="width:inherit;">Shells</a></li>
</ul>

</li>

<li><a href="vcrcrude.htm" target="mainFrame" accesskey="R"><u>R</u>aw vegetables</a></li><li>

<a href="vcotte.htm" target="mainFrame" accesskey="C">C<u>d</u>oocked vegetables</a></li>

<li><a href="intro_drinks.htm" target="mainFrame" class="MenuBarItemSubmenu" accesskey="D"><u>D</u>rinks</a>
<ul>
<li><a href="gass.htm" target="mainFrame" style="width:inherit;">With gas</a></li>
<li><a href="vino.htm" target="mainFrame" style="width:inherit;">Wines</a></li>
<li><a href="birra.htm" target="mainframe" style="width:inherit;">Beer</a></li>
</ul></li>
</ul>

 

Let's write just to give an example the menu's page and remind that it is essential to check that the address of files to which it refers is correct, relative to the directory where the file that contains the menu is placed

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Il menu di Lino Bertuzzi</title>
<meta name=·description· content="First level Menu "/>
<link href="../css/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<script src="../scripts/SpryMenuBar.js" type="text/javascript"></script>
</head> 

<body>

<ul id="MenuBar1" class="MenuBarVertical" >
<li><a href="intro_soups.htm" target="mainFrame" class="MenuBarItemSubmenu" accesskey="I"><u>I</u>ntroduction</a>

<ul>
<li><a href="pastas.htm" target="mainFrame" style="width:inherit;">Pastas</a></li>
<li><a href="minestre.htm" target="mainframe" style=width:inherit;">Soups</a></li>
</ul></li>

<li><a href="intro_meats.htm" target="mainFrame" class="MenuBarItemSubmenu" accesskey="C"><u>C</u>arne</a>
<ul>
<li><a href="chicken.htm" target="mainFrame" style="width:inherit;">Chicken</a></li>
<li><a href="beef.htm" target="mainFrame" style="width:inherit;">Beef</a></li>
</ul></li>

<li><a href="intro_seafood.htm" target="mainFrame class="MenuBarItemSubmenu" accesskey="S"><u>S</u>eafood</a>
</li>

<ul>
<li><a href="blue.htm" target="mainFrame" style="width:inherit;">Blue</a></li>
<li><a href="white.htm" target="mainframe" style="width:inherit;">White</a>
</li><a href="shells.htm" target="mainframe" style="width:inherit;">Shells</a></li>
</ul>

</li>

<li><a href="vcrcrude.htm" target="mainFrame" accesskey="R"><u>R</u>vegetables</a></li><li>

<a href="vcotte.htm" target="mainFrame" accesskey="D">Cooke<u>d</u> vegetables</a></li>

<li><a href="intro_drink.htm" target="mainFrame" class="MenuBarItemSubmenu" accesskey="D"><u>>D</u>rinks</a>
<ul>
<li><a href="gass.htm" target="mainFrame" style="width:inherit;">Gase</a></li>
<li><a href="vino.htm" target="mainFrame" style="width:inherit;">Winesi</a></li>
<li><a href="birra.htm" target="mainframe" style="width:inherit;">Beer</a></li>
</ul></li>
</ul>

</body>
</html>

 

 

A PRACTICAL TRICK

Here's how you can do to get and then adapt your menu

  1. Click this link to open the main menu of this site in your browser
  2. Save it with name the open page into a previously prepared directory OR check the text with the developer tool of your browser
  3. If tyou saved as, go to see what is into your previously prepared directory. You'll find the css and script and other needed files into a subdir
  4. If you did read and understand the previous samples You can:
    • open into a text editor
    • delete or add lines to menus and submenus by copy and paste the texts
    • change the text of items in menu and submenus, and save as htm
    • prepare all the pages that you want to link to
    • link the files to each

The menu can be used into an iframe or as you want. Enjoy

The same menu can be done only with <DIV>- ....... <DIV>