<! 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 "lang=" ZH-CN "> <pead> <meta http-equiv=" Content-type " Content= "text/html; charset=gb2312 "/> <title>css Menu Demo </title> <style type=" Text/css "> <!--*{margin:0;padding:0; border:0;} Body {font-family:arial, XXFarEastFont-Arial, serif; font-size:12px; } #nav {line-height:24px; list-style-type:none; background: #666; #nav a {display:block; width:80px; text-align:center; } #nav a:link {color: #666; text-decoration:none; } #nav a:visited {color: #666; text-decoration:none; } #nav a:hover {color: #FFF; text-decoration:none;font-weight:bold; #nav li {float:left; width:80px; background: #CCC; #nav li a:hover{background: #999; #nav Li ul {line-height:27px; list-style-type:none;text-align:left; Left: -999em; width:180px; Position:absolute; #nav Li ul Li{float:left; width:180px; Background: #F6F6F6; #nav Li ul a{display:block; width:180px;w\idth:156px;text-align:left;padding-left:24px; #nav Li ul a:link {color: #666; text-decoration:none; #nav Li ul a:visited {color: #666; text-decoration:none; #nav Li ul a:hover {color: #F3F3F3; text-decoration:none;font-weight:normal; Background: #C00; } #nav li:hover ul {left:auto; } #nav li.sfhover ul {left:auto; } #content {clear:left; }--> </style> <script type=text/javascript><!--//--><! [cdata[//><!--function Menufix () {var sfels = document.getElementById ("Nav"). getElementsByTagName ("Li"); for (var i=0 i<sfels.length; i++) {sfels[i].onmouseover=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmousedown=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseup=function () {this.classname+= (this.classname.length>0? "": "") + "Sfhover"; } sfels[i].onmouseout=function () {this.classname=this.classname.replace (? | ^), "sfhover\\b"); }} Window.onload=menufix; --><!]] ></script> </pead> <body> <ul id= "NAV" > <li> cloud-Habitat community <ul> <li><span> Foot This column </span></li> <li><span> network programming </span></li> <li><span> database </ span></li> <li><span> Source Download </span></li> <li><span> software download </span> </li> </ul> </li> <li> Service Introduction <ul> <li> service two </li> <li> service two </li> ;li> Service II </li> <li> Service two service two </li> <li> Service two service two service two </li> <li> service two </li> </ul > </li> <li> Successful case <ul> <li> case three </li> <li> case </li> <li> case three case three </li& Gt <li> Case three case three case three </li> </ul> </li> <li> About Us <ul> <li> we four ≪/li> <li> US four </li> <li> we four </li> <li> our four 111</li> </ul> </li> &L T;li> Online Demo <ul> <li> demo </li> <li> demo </li> <li> demo </li> <li> Demo Demo </li> <li> Demo Demo </li> <li> demo demo </li> <li> demo demo </li> <li> Demo Demo Demo Demo </li> </ul> </li> <li> Contact Us <ul> <li> Contact Contact Contact </li> <li> Contact Contact </L i> <li> Contact </li> <li> Contact </li> <li> Contact Contact </li> <li> Contact Contact </li> < li> Contact Contact </li> </ul> </li> </ul> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The second method:
In fact, the so-called two-level menu is almost, nothing more than a level two menu to define a layer, when the mouse on the first level of the menu to display this layer, and the mouse from the level of the menu moved away when the layer hidden. Therefore, the classic CSS level two menu can be derived from a number of different levels of level two menus, one of which is shown in the following picture, spring-style.
<! 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 "lang=" ZH-CN "> <pead> <meta http-equiv=" Content-type " Content= "text/html; charset=gb2312 "/> <title>css Menu Demo </title> <style type=" Text/css "> <!--*{margin:0;padding:0 ; border:0;} Body {font-family:arial, XXFarEastFont-Arial, serif; font-size:12px; #nav {line-height:24px; list-style-type:none; background: #666; width:80px; #nav a {display:block; width:80px; text-align:center; } #nav a:link {color: #666; text-decoration:none; } #nav a:visited {color: #666; text-decoration:none; } #nav a:hover {color: #FFF; text-decoration:none;font-weight:bold; #nav li {/*float:left*/; width:80px; background: #CCC; #nav li a:hover{background: #999; #nav Li ul {line-height:27px; list-style-type:none;text-align:left; Left: -999em; width:80px; Position:aBsolute; #nav Li ul li{float:left; width:80px; Background: #F6F6F6; #nav Li ul a{display:block; width:80px;w\idth:56px;text-align:left;padding-left:24px; #nav Li ul a:link {color: #666; text-decoration:none; #nav Li ul a:visited {color: #666; text-decoration:none; #nav Li ul a:hover {color: #F3F3F3; text-decoration:none;font-weight:normal; Background: #C00; } #nav li:hover ul {left:auto; } #nav li.sfhover ul {left:auto;position:static; } #content {clear:left; }--> </style> <script type=text/javascript><!--//--><! [cdata[//><!--function Menufix () {var sfels = document.getElementById ("Nav"). getElementsByTagName ("Li"); for (var i=0 i<sfels.length; i++) {sfels[i].onmouseover=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmousedown=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseup=function () { this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseout=function () {this.classname=this.classname.replace (? | ^), "sfhover\\b"); }} Window.onload=menufix; --><!]] ></script> </pead> <body> <ul id= "NAV" > <li> product Introduction <ul> <li> product One </li > <li> Products One </li> <li> products one </li> <li> product one </li> <li> product one </li> <li> Product One </li> </ul> </li> <li> Service Introduction <ul> <li> service two </li> <li> service two </li> <li> Services II </li> <li> Service two service two </li> <li> Service two service two service two </li> <li> service two </li> </ Ul> </li> <li> Successful case <ul> <li> case three </li> <li> case </li> <li> case three case three </l I> <li> Case three case three case three </li> </ul> </li> <li> About Us <ul> <li> we four </li> ;li> US four </li> <li> we four </Li> <li> US four 111</li> </ul> </li> <li> Online demo <ul> <li> demo </li> <l I> Demo </li> <li> demo </li> <li> Demo demo </li> <li> demo demo </li> <li> Demo Demo </li> <li> Demo Demo </li> <li> Demo Demo Demo demo </li> </ul> </li> <li> Contact Us <u l> <li> Contact Contact Contact </li> <li> Contact Contact </li> <li> Contact </li> <li> Contact </li > <li> Contact </li> <li> Contact Contact </li> <li> Contact Contact </li> </ul> </li> </ Ul> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
You can also turn the vertical level two menu into a horizontal one, as shown in the following two figures.
<! 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 "lang=" ZH-CN "> <pead> <meta http-equiv=" Content-type " Content= "text/html; charset=gb2312 "/> <title>css Menu Demo </title> <style type=" Text/css "> <!--*{margin:0;padding:0 ; border:0;} Body {font-family:arial, XXFarEastFont-Arial, serif; font-size:12px; } #nav {line-height:24px; list-style-type:none; background: #666; #nav a {display:block; width:80px; text-align:center; } #nav a:link {color: #666; text-decoration:none; } #nav a:visited {color: #666; text-decoration:none; } #nav a:hover {color: #FFF; text-decoration:none;font-weight:bold; #nav li {float:left; width:80px; background: #CCC; #nav li a:hover{background: #999; #nav Li ul {line-height:27px; list-style-type:none;text-align:left; Left: -999em; width:980px; Position:absolute; FloatLeft #nav Li ul li{float:left; width:80px; Background: #F6F6F6; #nav Li ul a{display:block; width:80px;text-align:center; #nav Li ul a:link {color: #666; text-decoration:none; #nav Li ul a:visited {color: #666; text-decoration:none; #nav Li ul a:hover {color: #F3F3F3; text-decoration:none;font-weight:normal; Background: #C00; } #nav li:hover ul {left:0; } #nav li.sfhover ul {left:0; } #content {clear:left; }--> </style> <script type=text/javascript><!--//--><! [cdata[//><!--function Menufix () {var sfels = document.getElementById ("Nav"). getElementsByTagName ("Li"); for (var i=0 i<sfels.length; i++) {sfels[i].onmouseover=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmousedown=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseup=function () {this.classname+= (this.classname.length>0?) " ": "") + "Sfhover"; } sfels[i].onmouseout=function () {this.classname=this.classname.replace (? | ^), "sfhover\\b"); }} Window.onload=menufix; --><!]] ></script> </pead> <body> <ul id= "NAV" > <li> product Introduction <ul> <li> product One </li > <li> Products One </li> <li> products one </li> <li> product one </li> <li> product one </li> <li> Product One </li> </ul> </li> <li> Service Introduction <ul> <li> service two </li> <li> service two </li> <li> Service II </li> <li> Service two service </li> <li> Service two service </li> <li> service two </li> </ul> & Lt;/li> <li> Success Stories <ul> <li> cases three </li> <li> case </li> <li> Case three cases </li> < Li> case Three cases </li> </ul> </li> <li> About Us <ul> <li> We four </li> <li> we four </l I> <li> US four </li> <li> our four 111</li> </ul> </li>;li> Online Demo <ul> <li> demo </li> <li> demo </li> <li> demo </li> <li> Demo Demo </ Li> <li> Demo </li> <li> demo </li> <li> Demo demo </li> <li> Demo Demo </li> < /ul> </li> <li> Contact <ul> <li> Contact Us </li> <li> Contact us </li> <li> Contact </L i> <li> Contact </li> <li> Contact </li> <li> Contact Contact </li> <li> Contact </li> </ ul> </li> </ul> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
<! 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 "lang=" ZH-CN "> <pead> <meta http-equiv=" Content-type " Content= "text/html; charset=gb2312 "/> <title>css Menu Demo </title> <style type=" Text/css "> <!--*{margin:0;padding:0; border:0;} Body {font-family:arial, XXFarEastFont-Arial, serif; font-size:12px; } #nav {line-height:24px; list-style-type:none; background: #666; #nav a {display:block; width:80px; text-align:center; } #nav a:link {color: #666; text-decoration:none; } #nav a:visited {color: #666; text-decoration:none; } #nav a:hover {color: #FFF; text-decoration:none;font-weight:bold; #nav li {float:left; width:80px; background: #CCC; #nav li a:hover{background: #999; #nav Li ul {line-height:27px; list-style-type:none;text-align:left; Left: -999em; width:980px; Position:absolute; Float:left; } #nav Li ul li{float:left; width:80px; Background: #F6F6F6; #nav Li ul a{display:block; width:80px;text-align:center; #nav Li ul a:link {color: #666; text-decoration:none; #nav Li ul a:visited {color: #666; text-decoration:none; #nav Li ul a:hover {color: #F3F3F3; text-decoration:none;font-weight:normal; Background: #C00; } #nav li:hover ul {left:auto; } #nav li.sfhover ul {left:auto; } #content {clear:left; }--> </style> <script type=text/javascript><!--//--><! [cdata[//><!--function Menufix () {var sfels = document.getElementById ("Nav"). getElementsByTagName ("Li"); for (var i=0 i<sfels.length; i++) {sfels[i].onmouseover=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmousedown=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseup=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseout=function () {this.classname=this.classname.replace (? | ^), "sfhover\\b"); }} Window.onload=menufix; --><!]] ></script> </pead> <body> <ul id= "NAV" > <li> product Introduction <ul> <li> product One </li> ; <li> Products One </li> <li> products one </li> <li> products one </li> <li> product one </li> <li> product one </li> </ul> </li> <li> Service Introduction <ul> <li> service two </li> <li> service two </li> ;li> Service II </li> <li> service </li> <li> Service two service </li> <li> service two </li> </ul> < /li> <li> Success Stories <ul> <li> cases three </li> <li> case </li> <li> case three cases </li> <li& GT Case Three cases </li> </ul> </li> <li> about Us <ul> <li> four </li> <li> we four </LI&G T <li> US four </li> <li> our four 111</li> </ul> </li> <li> Online Demo <uL> <li> Demo </li> <li> demo </li> <li> demo </li> <li> Demo demo </li> <li> Demo Demo </li> <li> demo </li> <li> Demo demo </li> <li> demo demo </li> </ul> </li& Gt <li> Contact Us <ul> <li> Contact </li> <li> Contact Us </li> <li> Contact </li> <li> Contact </li> <li> Contact </li> <li> Contact </li> <li> Contact Contact </li> </ul> </li& Gt </ul> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
The above several menus in IE, Firefox, Opera, Flock browser run through, but there is a problem, is in the first level of the menu after the mouse, level two menu will not disappear. This is a bug, not to mention it. In addition, there is a horizontal two-level menu, which is shown in the following figure. This menu runs in IE browser, but it is not working properly in Firefox, Opera, and flock browsers.
<! 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 "lang=" ZH-CN "> <pead> <meta http-equiv=" Content-type " Content= "text/html; charset=gb2312 "/> <title>css Menu Demo </title> <style type=" Text/css "> <!--*{margin:0;padding:0; border:0;} Body {font-family:arial, XXFarEastFont-Arial, serif; font-size:12px; #nav {line-height:24px; list-style-type:none; background: #666; width:80px; #nav a {display:block; width:80px; text-align:center; } #nav a:link {color: #666; text-decoration:none; } #nav a:visited {color: #666; text-decoration:none; } #nav a:hover {color: #FFF; text-decoration:none;font-weight:bold; #nav li {/*float:left*/; width:80px; background: #CCC; #nav li a:hover{background: #999; #nav Li ul {line-height:27px; list-style-type:none;text-align:left; Left: -999em; width:180px; Position:absolute; #nav Li ul li{float:left; width:180px; Background: #F6F6F6; #nav Li ul a{display:block; width:180px;w\idth:156px;text-align:left;padding-left:24px; #nav Li ul a:link {color: #666; text-decoration:none; #nav Li ul a:visited {color: #666; text-decoration:none; #nav Li ul a:hover {color: #F3F3F3; text-decoration:none;font-weight:normal; Background: #C00; } #nav li:hover ul {left:auto; } #nav li.sfhover ul {left:auto; } #nav li.sfhover a {float:left; } #content {clear:left; }--> </style> <script type=text/javascript><!--//--><! [cdata[//><!--function Menufix () {var sfels = document.getElementById ("Nav"). getElementsByTagName ("Li"); for (var i=0 i<sfels.length; i++) {sfels[i].onmouseover=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmousedown=function () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseup=funCtion () {this.classname+= (this.classname.length>0?) "": "") + "Sfhover"; } sfels[i].onmouseout=function () {this.classname=this.classname.replace (? | ^), "sfhover\\b"); }} Window.onload=menufix; --><!]] ></script> </pead> <body> <ul id= "NAV" > <li> product Introduction <ul> <li> product One </li> ; <li> Products One </li> <li> products one </li> <li> products one </li> <li> product one </li> <li> product one </li> </ul> </li> <li> Service Introduction <ul> <li> service two </li> <li> service two </li> ;li> Service II </li> <li> Service two service two </li> <li> Service two service two service two </li> <li> service two </li> </ul > </li> <li> Successful case <ul> <li> case three </li> <li> case </li> <li> case three case three </li& Gt <li> Case three case three case three </li> </ul> </li> <li> About Us <ul> <li> we four </li> <li> We four </li> <li> we four</li> <li> Our four 111</li> </ul> </li> <li> Online demo <ul> <li> demo </li> & Lt;li> Demo </li> <li> demo </li> <li> Demo Demo Demo </li> <li> demo demo </li> <li> Demo Demo </li> <li> demo demo </li> <li> Demo Demo Demo demo </li> </ul> </li> <li> Contact Us & lt;ul> <li> Contact Contact Contact </li> <li> Contact Contact </li> <li> Contact </li> <li> Contact </ li> <li> Contact </li> <li> Contact Contact </li> <li> Contact Contact </li> </ul> </li> ;/ul> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Above cloud-dwelling community file package download