How to make a drop-down menu of HTML

How to make a drop-down menu of HTML

During creation of the menu of the website it is possible to face a problem of limitation of space, need to save the place and to avoid a heap of excess information. All this conveniently is solved elements which disappear when are not necessary. If there is a wish to avoid use of scripts, such menu can be created by HTML and css.

Instruction

1. Make the menu, define its structure. Arrange elements in an order, convenient for future user. Think over clear and competent names of sections. Define points which should be dropping out, and subparagraphs which will be in these drop-down lists.

2. Register the thought-up structure by means of HTML tags. It will look approximately as follows: <div id= "" vmenu""> <ul> <li> <href= "" #""> Link 1. </a> </li> <li> <href= "" #""> Link 2. </a> <ul> <li> <href= "" #""> Paragraph 2.1. </a> </li> <li> <href= "" #""> Paragraph 2.2. </a> </li> <li> <href= "" #""> Paragraph 2.3. </a> </li> </ul> </li> <li> <href= "" #""> Link 3. </a> <ul> <li> <href= "" #""> Paragraph 3.1. </a> </li> <li> <href= "" #""> Paragraph 3.2. </a> </li> <li> <href= "" #""> Paragraph 3.3. </a> </li> <li> <href= "" #""> Paragraph 3.4. </a> </li> </ul> </li> </ul> </div>

3. Place all menus in the <div> block. Set the identifier id that will allow to assign further features only to this block, without mentioning the others. Enter a certain name for which describe properties in the following steps in the identifier.

4. Create lists where <ul> - the list, and <li> - each of its lines. Add for all future ssylkok which should create a drop-down menu, the list with subparagraphs. Turn names of menu items into links, having imprisoned them in a tag <a>. Assign to its href parameter the address of the page which the link will indicate.

5. Set properties of the list through css, having entered them to the css-file: #vmenu ul {margin: 0px; padding: 0px; list-style: none; width: 250px; }. Set equal to zero padding indents - an indent inside and margin - an indent outside of a list element. Specify list-style - style of the marked list, by default with points which at none value clean up. Enter width list width.

6. Add member property of the list: #vmenu ul li {position: relative; }. Specify positioning parameter, that is arrangements of the position elements. Assign it relative relative value to define arrangement of a drop-down menu rather initial. The created menu will be vertical.

7. Specify properties for the list located in an element of other list: #vmenu li ul {position: absolute; left: 250px; top: 0; display: none; }. Assign to the parameter of positioning position absolute value to carry out absolute positioning of a submenu concerning a menu item. Set arrangement by means of a space indent of left and on top top at the left. Determine the display element display option as none as initially drop-down list should not be visible.

8. Enter parameters for links: #vmenu ul li a {display: block; padding: 5px; text-decoration: none; color:#606060; background:#d8d8d8; }. Assign to display display option the block value doing an element to block. At the same time he visible also behaves as the block. Set padding indent, text color of the link color, background color of the link background, style of the link text-decoration. None value removes underlining by default.

9. Set action at guidance of the cursor: #vmenu li: hover ul {display: block; }. Specify that at guidance of the cursor on a line of the li list, the ul list located in it becomes visible.

10. Add at will parameters of color or the image for a background, horizontal lines, a font of links and other properties defining appearance of the menu.

Author: «MirrorInfo» Dream Team


Print