Introduction to CSS page layouts 14: Vertical dropdown and multi-level pop-up menus _ basic Tutorials

Source: Internet
Author: User
After learning the last tutorial, I think it is much easier to study this section.
Horizontal menu is through div and javasprict to achieve Drop-down control, vertical menu? The answer is yes. What we're going to do now is a vertical menu, CSS code:

UL {margin:0; padding:0; list-style:none; width:120px; border-bottom:1px solid #ccc; font-size:12px;}
UL li {position:relative;}
Li ul {position:absolute; left:119px; top:0; display:none;}
Ul Li a {width:108px display:block; text-decoration:none; color: #666666; background: #fff; padding:5px; border:1px Solid #ccc; border-bottom:0px;}
UL li a:hover {background-color: #ddd;}
* To solve the UL in IE under the incorrect display of the problem * *
* HTML ul li {float:left; height:1%;}
* HTML ul li a {height:1%;}
/* END * *
Li:hover Ul,li.over ul {display:block;}


CSS code to write basically maintained with the same idea of horizontal navigation, the difference is, in order to achieve the navigation in the navigation and the main air in the implementation of the mouse interaction at the same time, to maintain its relative position, we used the UL li{} used position:relative; So that its positioning mode into relative positioning. The Position:absolute of Li ul{} is the same as that of the navigation, and the position of the mouse interaction is consistent with the absolute positioning method.
Perhaps you have found that here in the CSS code has not tailed added a section of annotation definition * HTML ul li with * html ul li A. CSS hack is used here because different browsers have different parsing of the code, which is used to display the same effect on each browser. This code only can parse by IE browser, other browsers ignore.
The final display effect of this example is as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> dropdown vertical and Multilevel pop-up menu www.aa25.cn</title> <script type=" Text/javascript ">< !--//--><! [cdata[//><!--startlist = function () {if (Document.all&&document.getelementbyid) {Navroot = document.getElementById ("Nav"); For (i=0 i<navroot.childnodes.length; i++) {node = navroot.childnodes[i]; if (node.nodename== "LI") {node.onmouseover=function () {this.classname+= "over"; } node.onmouseout=function () {This.classname=this.classname.replace ("Over", ""); }}}} window.onload=startlist; The; <!]] ></script> <style> ul {margin:0; padding:0; list-style:none; width:120px; border-bottom:1px solid #ccc; font-size:12px;} UL li {position:relative;} Li ul {position:absolute; left:119px; top:0; display:none;} Ul Li a {width:108px display:block; text-decoration:none; color: #666666; background: #fff; padding:5px; border:1px Solid #ccc; border-bottom:0px;} UL li a:hover {background-color: #ddd;} * To solve the UL in IE under the incorrect display of the problem aa25.cn*/* html ul li {float:left; height:1%} * HTML ul li a {height:1%;} /* End * * Li:hover ul,li.over ul {display:block;} </style> </pead> <body> <ul id= "NAV" > <li> article <ul> <l I>css Tutorials </li> <li>dom Tutorials </li> <li>xml Tutorials </li> <li& Gt Flash Tutorials </li> </ul> </li> <li> reference <ul> <li>xhtm L</li> <li>XML</li> <li>CSS</li> </ul> </li> <li>blog <ul> <li> all </li> <li> Web technology </li> <li>ui Technology </li> <li>flash technology </li> </ul> </li> <li> rock </li> <li> Pure Music </l i> <li> classical Melody </li> <li> movie soundtrack </li> </ul> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
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.