<img title="sexydropdownmenu2010" style="max-width:90%" style="max-width:90%" alt="sexydropdownmenu2010" src="http://images.cnblogs.com/cnblogs_com/Jinglecat/WindowsLiveWriter/CSSjQuerySexy_49E6/sexydropdownmenu2010_thumb.png" style="max-width:90%" border="0"> <br>如何实现 <br>Step 1 HTML <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="48963" class="copybut" id="copybut48963" onclick="doCopy('code48963')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code48963"> <br><ul class="topmenu"> <br><li><a href="#">Home</a></li> <br><li> <a href="#">Tutorials</a> <br><ul class="submenu1"> <br><li><a href="#">Ch1</a></li> <br><li> <a href="#">Ch2</a> <br><ul class="submenu11"> <br><li> <a href="#">Ch21</a> <br><ul class="submenu11"> <br><li> <a href="#">Ch211</a> <br><ul class="submenu11"> <br><li> <a href="#">Ch2111</a> <br><ul class="submenu11"> <br><li><a href="#">Ch21111</a></li> <br><li><a href="#">Ch21112</a></li> <br><li><a href="#">Ch21113</a></li> <br><li><a href="#">Ch21114</a></li> <br><li><a href="#">Ch21115</a></li> <br><li><a href="#">Ch21116</a></li> <br> </ul> <br> </li> <br><li><a href="#">Ch2112</a></li> <br><li><a href="#">Ch2113</a></li> <br><li><a href="#">Ch2114</a></li> <br><li><a href="#">Ch2115</a></li> <br> </ul> <br> </li> <br><li><a href="#">Ch212</a></li> <br><li><a href="#">Ch213</a></li> <br><li><a href="#">Ch214</a></li> <br> </ul> <br> </li> <br><li> <a href="#">Ch22</a> <br><ul class="submenu11"> <br><li><a href="#">Ch221</a></li> <br><li><a href="#">Ch222</a></li> <br><li><a href="#">Ch223</a></li> <br> </ul> <br> </li> <br><li><a href="#">Ch23</a></li> <br> </ul> <br> </li> <br><li> <a href="#">Ch3</a> <br><ul class="submenu11"> <br><li><a href="#">Ch31</a></li> <br><li><a href="#">Ch32</a></li> <br> </ul> <br> </li> <br> </ul> <br> </li> <br><li> <a href="#">Resources</a> <br><ul class="submenu1"> <br><li><a href="#">Sub Nav Link</a></li> <br><li><a href="#">Sub Nav Link</a></li> <br> </ul> <br> </li> <br><li><a href="#">About Us</a></li> <br><li><a href="#">Advertise</a></li> <br><li><a href="#">Submit</a></li> <br><li><a href="#">Contact Us</a></li> <br> </ul> <br> </div> <br>Step 2 CSS <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="40677" class="copybut" id="copybut40677" onclick="doCopy('code40677')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code40677"> <br><style type="text/css"> <BR>/* Header */ <BR>body <BR>{ <BR>margin: 0; <BR>padding: 0; <BR>font: 10px normal Arial, Helvetica, sans-serif; <BR>background: #ddd url(images/sexydropdownmenu/body_bg.gif) repeat-x; <BR>} <BR>.container <BR>{ <BR>width: 960px; <BR>margin: 0 auto; <BR>position: relative; <BR>} <BR>#header <BR>{ <BR>background: url(images/sexydropdownmenu/header_bg.gif) no-repeat center top; <BR>padding-top: 120px; <BR>} <BR>#header .version <BR>{ <BR>color: #111; <BR>font-size: 40px; <BR>padding: 38px 450px 7px 0; <BR>text-align: right; <BR>display: block; <BR>position: absolute; <BR>top: 0; <BR>right: 0; <BR>} <BR>#header .disclaimer <BR>{ <BR>color: #999; <BR>padding: 100px 0 7px 0; <BR>text-align: right; <BR>display: block; <BR>position: absolute; <BR>top: 0; <BR>right: 0; <BR>} <BR>#header .disclaimer a <BR>{ <BR>color: #ccc; <BR>} <BR>/* Sexy Drop Down Menu */ <BR>ul.topmenu <BR>{ <BR>list-style: none; <BR>padding: 0 20px; <BR>margin: 0; <BR>float: left; <BR>width: 920px; <BR>background: #222; <BR>font-size: 1.2em; <BR>background: url(images/sexydropdownmenu/topnav_bg.gif) repeat-x; <BR>} <BR>ul.topmenu li <BR>{ <BR>float: left; <BR>margin: 0; <BR>padding: 0 15px 0 0; <BR>position: relative; /*--Declare X and Y axis base for sub navigation--*/ <BR>} <BR>ul.topmenu li a, ul.topmenu li a.hover <BR>{ <BR>padding: 10px 5px; <BR>color: #fff; <BR>display: block; <BR>text-decoration: none; <BR>float: left; <BR>} <BR>ul.topmenu li a.hover, ul.topmenu li a:hover <BR>{ <BR>background: url(images/sexydropdownmenu/topnav_hover.gif) no-repeat center top; <BR>} <BR>ul.topmenu li span <BR>{ <BR>/*--Drop down trigger styles--*/ <BR>width: 17px; <BR>height: 35px; <BR>float: left; <BR>background: url(images/sexydropdownmenu/subnav_btn.gif) no-repeat center top; <BR>} <BR>ul.topmenu li span.hover <BR>{ <BR>background-position: center bottom; <BR>cursor: pointer; <BR>} <BR>ul.topmenu li ul.submenu1 <BR>{ <BR>/*--Hover effect for trigger--*/ <BR>list-style: none; <BR>position: absolute; /*--Important - Keeps submenu1 from affecting main navigation flow--*/ <BR>left: 0; <BR>top: 35px; <BR>background: #333; <BR>margin: 0; <BR>padding: 0; <BR>display: none; <BR>float: left; <BR>width: 170px; <BR>border: 1px solid #111; <BR>} <BR>ul.topmenu li ul.submenu1 li <BR>{ <BR>margin: 0; <BR>padding: 0; <BR>border-top: 1px solid #252525; /*--Create bevel effect--*/ <BR>border-bottom: 1px solid #444; /*--Create bevel effect--*/ <BR>clear: both; <BR>width: 170px; <BR>} <BR>ul.topmenu li ul.submenu1 li a <BR>{ <BR>float: left; <BR>width: 145px; <BR>background: #333 url(images/sexydropdownmenu/dropdown_linkbg.gif) no-repeat 10px center; <BR>padding-left: 20px; <BR>} <BR>ul.topmenu li ul.submenu1 li a:hover <BR>{ <BR>/*--Hover effect for submenu1 links--*/ <BR>background: #222 url(images/sexydropdownmenu/dropdown_linkbg.gif) no-repeat 10px center; <BR>} <BR>ul.topmenu li ul.submenu1 li ul.submenu11 <BR>{ <BR>list-style: none; <BR>position: absolute; /*--Important - Keeps submenu11 from affecting main navigation flow--*/ <BR>left: 170px; <BR>top: -2px; <BR>background: #333; <BR>margin: 0; <BR>padding: 0; <BR>display: none; <BR>float: left; <BR>width: 170px; <BR>border: 1px solid #111; <BR>} <BR></style> <br> </div> <br>Step 3 jQuery <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="18651" class="copybut" id="copybut18651" onclick="doCopy('code18651')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code18651"> <br><script type="text/javascript"> <BR>$(document).ready(function() { <BR>// Top Menu <BR>$("ul.submenu1").parent().append("<span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.submenu1*) <BR>$("ul.topmenu li span").click(function() { //When trigger is clicked... <BR>//Following events are applied to the submenu1 itself (moving submenu1 up and down) <BR>$(this).parent().find("ul.submenu1").slideDown('fast').show(); //Drop down the submenu1 on click <BR>$(this).parent().hover(function() { <BR>}, function() { <BR>$(this).parent().find("ul.submenu1").slideUp('slow'); //When the mouse hovers out of the submenu1, move it back up <BR>}); <BR>//Following events are applied to the trigger (Hover events for the trigger) <BR>}).hover(function() { <BR>$(this).addClass("hover"); //On hover over, add class "hover" <BR>}, function() { //On Hover Out <BR>$(this).removeClass("hover"); //On hover out, remove class "hover" <BR>}); <br><br>$("ul.topmenu li ul.submenu1 li").hover(function() { <BR>$(this).find("ul.submenu11:first").show("slow"); <BR>}, function() { <BR>$(this).find("ul.submenu11:first").hide("fast"); <BR>}); <BR>}); <BR></script> <br> </div> <br>演示代码<br><a href="http://www.jb51.net/jiaoben/23955.html">http://www.jb51.net/jiaoben/23955.html</a>