Div + css list menu instance tutorial

Source: Internet
Author: User

Have you seen CSS menus on these lists? Fancy decisions? Of course you! Well, this is a convenient tutorial if you want to create a quick CSS menu and be able to control its appearance.

Step 2
Create a zone on your HTML page and create an unordered list area, as shown in the following code:

<Div>
<Ul id = "nav">
<Li> <a href = "home.htm"> Home </a> </li>
<Li> <a href = "about.htm"> About Us </a> </li>
<Li> <a href = "products.htm"> Products </a> </li>
<Li> <a href = "services.htm"> Services </a> </li>
<Li> <a href = "contact.htm"> Contact Us </a> </li>
</Ul>
</Div>
 

As you can see in the code, I will contact all of our list items for general HTML web pages. When you use the above code on your website, you may want to link it to a specific webpage on your website. It also notifies us that the ID list we have considered is called navigation. I will rename the name quickly, so don't worry too much, now. In any case, let's proceed to step 2.

Step 2
Between the first section, copy and paste the following code on the webpage in the

<Style type = "text/css">
. Menustyling {
Width: 300px;
Margin: 0px;
Padding: 0px;
Background-color: # fff;
}
</Style>
 

It looks strange to paste your code at a glance, but when you look at the details, it is very simple. First, the attributes, width, Edge, fill, and background color that I specified. For each of these attributes, I assign them value. Declare a style-appeal. M enustyling-only partial h t ml objects. You need to call it. The ID you use together with the marked area name:

<Div class = "menustyling">
If you replace the HTML and the above code in the tag area list, you may not see much change. The main advantage of the packaging list is centered around a tag area, making it easy to modify the background color, Edge, fill, and so on in your list in the future. You only need to change the menustyling block in the code. You do not have any contact list attributes. This decoupling style information content is a very powerful tool for making CSS in your toolbox.

Step 2
Next, you will delete the key points from the list, and we may also fix the fill and profit margin list. Add the following code directly below the previous code to paste the

. Menustyling ul {
List-style: none;
Padding: 0px;
Margin: 0px;
}
 

Can you tell the difference between the scenes? They all have the same name-m enustyling. However, note that menustyling in the second version contains the UL-tagged title. This means that any ul authentication content is placed in the specific style of the menustyling umbrella. Menustyling UL certification category.

You should have shown the following picture in a simple list:

We started to make some basic modifications, the previous page on our menu. We will pick up from there and we will leave this page.

Step 2
Now back to the style tag, copy and paste the "/style" tag at the following level:

Nav li {

Background-color: # A4DFF1;
Display: block;
Width: 196px;
Line-height: 20px;
Height: 20px;
Margin: 0px;
 
Font-family: Arial, Helvetica, sans-serif;
Font-size: 8pt;
Font-weight: bold;
Padding-left: 3px;
Padding-top: 7px;
Color: #000000;
}

First of all, please note that the # Navigation umbrella under all the above-mentioned style documents. This simple fact allows me to explain each line:

# Navigation sets up (
This means that this effect will change the configuration item (Li), which contains contact (1) which will appear in the menu.


--------------------------------------------------------------------------------

Background color: # A4DFF1;
This line is quite self-evident. Set all hypertext link list items in the background color to a blue sky.


--------------------------------------------------------------------------------

Display: block;
This means that, in this case, the configuration item will be displayed as a block-level element with the elements before and after the broken line.


--------------------------------------------------------------------------------

Width: 196px;
Height: 20px;
Margin: 0px;

This is quite self-evident. These three lines specify the width, height, and profit margin factors.

Font-family: Arial, Helvetica, sans-serif;
Font-size: 8pt;
Font-weight: bold;
Color: #000000;

The font specified by the above line is the text of your link list. In general, there is no tricky explanation here.


--------------------------------------------------------------------------------

Text modifier: none;
By default, all links are important. This line of code removes the emphasis from the text menu in your list.


--------------------------------------------------------------------------------

Fill left: 3px;
Fill Top: 7px;
This is just some fill position where the font is a little away from leaving and in the vertical center of the project.

When you preview your list, you should see the picture of your effort, your labor shown:

As shown in the previous figure, click here to view the life in the example above.

Step 2
Now, although still in style tag, paste the following categories:

# Nav li a: hover {
Color: # FFFFFF;
Background-color: # 77B8CC;
}

This will make the style of the List project awkward. In other words, when the user moves the mouse cursor link and the appearance is hovering over the sky, change the menu item based on the code you specified above. In our case, the only change you will see is the corresponding color and background color list item.

And you now have a CSS menu in the work list.

Tip: to get more images from this configuration item that you can change colors, for example, if I change the background color line # Navigation question: hover the following lines:

Background-image: url(buttons_over.jpg );

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.