Let's take a look at this piece of code. About CSS and HTML.

Source: Internet
Author: User

The problem is: Originally to achieve the two-level menu scaling, the results can not be scaled ...

The code is as follows:

/*CSS Section*/#navigation > UL{List-style-type:None;margin:0px;padding:0px;}#navigation > Ul > Li{Border-bottom:1px solid #ED9F9F;}#navigation > Ul > li > A{Display:Block;/*Block Display*/padding:5px 5px 5px 0.5em;text-decoration:None;Border-left:12px Solid #711515;/*thick red side on the left*/Border-right:1px solid #711515;/*Right Shadow*/}#navigation > Ul > li > A:link, #navigation > Ul > li > A:visited{Background-color:#c11136;Color:#FFFFFF; }#navigation > Ul > li > A:hover{/*when the mouse passes*/Background-color:#990020;/*change the background color*/Color:#ffff00;/*Change text color*/}/*Level Two menu*/#navigation u li ul{List-style-type:None;margin:0px;padding:0px 0px 0px 0px;}#navigation ul Li ul Li{Border-top:1px solid #ED9F9F;}#navigation ul Li ul li a{Display:Block;padding:3px 3px 3px 0.5em;text-decoration:None;Border-left:28px Solid #a71f1f;Border-right:1px solid #711515;}#navigation ul Li ul Li A:link, #navigation ul Li ul Li a:visited{Background-color:#e85070;Color:#FFFFFF;}#navigation ul Li ul li a:hover{Background-color:#c2425d;Color:#ffff00;}/*Hide sub-menu*/#navigation ul Li Ul.myhide{Display:None;}/*Show sub-menu*/#navigation ul Li Ul.myshow{Display:Block;}
/*HTML Section*/<!  DOCTYPE html>{var oU1 = document.getElementById ("Listul");            var aLi = ou1.childnodes;            var OA; for (Var i=0;i<ali;i++) {//If the child element is Li, and this Li has a sub-menu ul if (ali[i].tagname = = "Li" && ali[i        ].getelementsbytagname ("ul"). Length) {OA = Ali[i].firstchild;        Find the hyperlink Oa.onclick = change; Adding a standalone function dynamically}}} function change (){//Through the parent element Li, find the sibling element li var oseconddiv = this.parentNode.getElementsByTagName ("ul") [0];            CSS alternate replacement to achieve display, hide if (oseconddiv.classname = = "Myhide") Oseconddiv.classname = "Myshow";        else Oseconddiv.classname = "Myhide"; }    </script>

This is an example I read from the book, when I wrote it, I found it seemed to have problems, and then came to you for help.

Let's take a look at this piece of code. About CSS and HTML.

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.