CSS making simple drop-down menu

Source: Internet
Author: User

Important: Locate, hide, display.

(i) First build a two-time list

<ulID= "UL1">        <Li>Home</Li>        <Li>second page<ul>                        <Li><ahref= ' # '>One</a></Li>                        <Li><ahref= ' # '>Both</a></Li>                        <Li><ahref= ' # '>Three</a></Li>                </ul>        </Li>        <Li>Third page</Li></ul>

(b) Set the style in CSS: Display the border of list items, set width and height, and set a background image for good looking.

Li {        border:1px solid gray;                width: 80px;         height: 35px;         background-image: url (a1.png);}

Very ugly.

(c) Remove the dots.

Li {List-style-type: none;}

(d) Let the head list items float horizontally

#ul1 >li {float: left;}   " > "refers to only the LI element under the UL1 list, excluding the next-level LI element in the child element.

(v) Reposition the level two menu and align the second page

#ul1  ul{position:absolute;         Top: 52px;           Left: 90px;            }

(vi) Hide the level two menu

#ul1 ul {display:none}

(vii) When the mouse over the corresponding menu, the level two menu shows the red

{Display:block;}

(eight) in order to look good, you can set the mouse across colors.

{background:Gray;                cursor:pointer;}

You can also set style center alignment, remove link underline, etc.

The final code is as follows:

<style>li{Border:1px solid Gray;width:80px;Height:35px;Background-image:URL (a1.png);List-style-type:None;text-align:Center;Padding-top:8px;}#ul1 >li{float: Left;}#ul1 ul{position:Absolute;Top:60px; Left:90px;Display:None; }#ul1 Li:hover ul{Display:Block;}#ul1 Li:hover{background:Gray;cursor:Pointer;}a{text-decoration:None;}</style>

CSS making simple drop-down menu

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.