Div + CSS layout entry Guide (4)
List of the use of the production menu <li>
The study began before this section, make sure you have the light before the contents of the sections into a DIV, CSS to index.htm and css.css document.
This section I will tell you how to list <li> to create the menu.
<div Id="menu">
<ul>
<li> <a Href="#"> Home </ a> </ li>
<li Class="menuDiv"> </ li>
<li> <a Href="#"> blog </ a> </ li>
<li Class="menuDiv"> </ li>
<li> <a Href="#"> design </ a> </ li>
<li Class="menuDiv"> </ li>
<li> <a Href="#"> Album </ a> </ li>
<li Class="menuDiv"> </ li>
<li> <a Href="#"> Forum </ a> </ li>
<li Class="menuDiv"> </ li>
<li> <a Href="#"> on </ a> </ li>
</ Ul>
</ Div>
The above is this part of the structure, on <ul> </ ul>, <li> </ li> HTML these two elements you to make reference to relevant content bar, their most important role is in HTML to List in the form of some of the information to display.
Another point that we need to have to distinguish very clearly, when in HTML defined as id = "divID", in the corresponding CSS syntax is set divID () # if defined in the HTML class = "divID", in the corresponding CSS syntax settings yes. divID.
If id = "divID" This layer includes a <img> </ img>, then img in the corresponding CSS syntax settings should be # divID img (), the same, if it is included in the class = "divID" layer, it should be set up grammar yes. divID img () This is the hope that we have to clear.
In addition, all the elements in HTML can be defined, for example, table, tr, td, th, form, img, input … and so on, if you want to set up in the CSS them directly into the elements of the name of Canada on the one pair of braces () on it. All the CSS code should be written in large () brackets.
In line with the above, we first css.css writes the following code:
# Menu ul (list-style: none; margin: 0px;)
# Menu ul li (float: left;)
Explain:
# Menu ul (list-style: none; margin: 0px;)
List-style: none, this one is to abolish the list before, because we do not need these points.
Margin: 0px, this one is the deletion of UL indentation, it can make a list of all the contents are not indented.
# Menu ul li (float: left;)
Float here: the left is about to content on the same line, the use of a floating attributes (float).
With this step, we first proposed to preserve preview effects, we have to add the following text, the effect is as follows:
![]()
At this time, the list is arranged in his party, we have # menu ul li () to add code margin: 0 10px
# Menu ul (list-style: none; margin: 0px;)
# Menu ul li (float: left; margin: 0 10px)
Margin: 0 10px role is to list the contents between a 20-pixel distance (Left: 10 px, and the right: 10 px), preview the effect of the following:

Now, the prototype has been out, we come back the location of the fixed menu, the code changed as follows:
# Menu (padding: 20px 20px 0 0)
/ * Use padding: 20px 20px 0 0 menu to the fixed location * /
# Menu ul (float: right; list-style: none; margin: 0px;)
/ * Add the float: right makes menu at the right pages * /
# Menu ul li (float: left; margin: 0 10px)
At this time, location have been identified, but concept map, the menu options are between a Shuxian, how do?
After all, we have already had a good stay in the air <li class = "menuDiv"> </ li>, in order to join the Shuxian to use it.
In accordance with the above said, we will add the following code:
. MenuDiv (width: 1px; height: 28px; background: # 999)
Preview to preserve, Shuxian have been out? On the code not speak, and it should be very easy to understand.
![]()
However, the menu options at the top of the text but, we further amendments into the following code:
# Menu ul li (float: left; margin: 0 10px; display: block; line-height: 28px)
On display: block; line-height: 28px we can to see this manual, I do not speak of.
Basically, the effect has been achieved, and the rest of the menu is modified form of hyperlinks, css.css, add the following code:
# Menu ul li a: link, # menu ul li a: visited (font-weight: bold; color: # 666)
# Menu ul li a: hover ()
This is to say, not speak, the final results are as follows:

This section here on the end, the way the material available to everyone:
Figure idea: Download
HTML and CSS source file: Download
Tags: CSS DIV, div class, div css, div css Guide, div css layout, div location






Leave a Reply