像京东商城 商品页面 的 鼠标放上去就自动展开的菜单怎么做啊 css 和javascript 都可以

html-css026

像京东商城 商品页面 的 鼠标放上去就自动展开的菜单怎么做啊 css 和javascript 都可以,第1张

给你一个类似的,需要展开的菜单你加一个样式默认隐藏,然后在JS里加一个事件显示就好了

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />

<title>CSS+XHTML代码</title>

</head>

<style type="text/css">

/* ================================================================

This copyright notice must be untouched at all times.

The original version of this stylesheet and the associated (x)html

is available at http://www.cssplay.co.uk/menus/page_menu2.html

Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.

This stylesheet and the associated (x)html may be modified in any

way to fit your requirements.

=================================================================== */

body {

background: #fff

font-family: "Lucida Grande", Helvetica, Arial, sans-serif

font-size: 12px

}

#hoverpage ul#outer li div p {font-size:12pxline-height:16pxmargin:5px 0 15px 0}

#hoverpage ul#outer li div h2 {line-height:1emcolor:#585font-size:1.5emfont-weight:normalmargin-top:0font-family:verdana, sans-serif}

#hoverpage ul#outer li div h3 {line-height:1emcolor:#66afont-size:1.2emfont-weight:normalmargin-top:0}

#hoverpage ul#outer li div h3.clear {clear:left}

#hoverpage {width:650pxheight:450pxborder:1px solid #aaabackground:#fffposition:relativez-index:500overflow:hiddentext-align:left}

#hoverpage table {border-collapse:collapsemargin:-1px}

#hoverpage ul#outer {background:transparentpadding:0margin:0list-style:none}

#hoverpage ul#outer li.page {display:inline} /* needed for IE to function correctly */

#hoverpage ul#outer li.page a.menuitem {text-decoration:none}

#hoverpage ul#outer li.page i {position:absolutedisplay:blockheight:25pxright:500pxbackground:transparentcursor:defaultz-index:100text-align:righttext-decoration:nonecolor:#080font-style:normalcursor:pointer}

#hoverpage ul#outer li.p1 i {top:30px}

#hoverpage ul#outer li.p2 i {top:55px}

#hoverpage ul#outer li.p3 i {top:80px}

#hoverpage ul#outer li.p4 i {top:105px}

#hoverpage ul#outer li.p5 i {top:130px}

#hoverpage ul#outer li.page div {display:blockwidth:600pxheight:400pxpadding:25pxfont-weight:normalcolor:#444}

#hoverpage ul#outer li.p1 div {background:#fff url(page1_back.jpg)}

#hoverpage ul#outer li.p2 div {background:#fff url(page2_back.jpg)}

#hoverpage ul#outer li.p3 div {background:#fff url(page3_back.jpg)}

#hoverpage ul#outer li.p4 div {background:#fff url(page4_back.jpg)}

#hoverpage ul#outer li.p5 div {background:#fff url(page5_back.jpg)}

#hoverpage ul#outer li div img {border:1px solid #888float:rightmargin:0 10px 5px 0}

#hoverpage ul#outer li div p.big {line-height:1emcolor:#004font-size:1.5em}

#hoverpage ul#outer li div a {color:#00ctext-decoration:underline}

#hoverpage ul#outer li div em {display:blockwidth:190pxheight:230pxfloat:leftbackground:transparent url(current.gif) no-repeatmargin-right:10px}

#hoverpage ul#outer li.p1 div em {background-position: 21px 0}

#hoverpage ul#outer li.p2 div em {background-position: 21px 25px}

#hoverpage ul#outer li.p3 div em {background-position: 21px 50px}

#hoverpage ul#outer li.p4 div em {background-position: 21px 75px}

#hoverpage ul#outer li.p5 div em {background-position: 21px 100px}

#hoverpage ul#outer li.page div a:hover {text-decoration:none}

#hoverpage ul#outer li.page a:hover {white-space:normal} /* for IE6 */

#hoverpage ul#outer :hover div {position:absoluteleft:0top:0}

#hoverpage ul#outer a:hover i {color:#66afont-weight:bold} /* for IE6 */

#hoverpage ul#outer :hover a i {color:#66afont-weight:bold}

#hoverpage ul#outer div ul li {line-height:20pxfont-size:0.9emcolor:#256list-style-type:disc}

#hoverpage ul#outer div ul li a {line-height:20pxfont-size:1.1emcolor:#c00}

#hoverpage ul#outer div dl dd {line-height:20pxfont-size:1.1emcolor:#448}

#hoverpage ul#outer div dl dt {line-height:30pxfont-size:1.3emcolor:#333}

</style>

<body>

<div id="hoverpage">

<ul id="outer">

<li class="page p1"><a href="#nogo" class="menuitem"><i>Products</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="bags.jpg" alt="" />

<h2>Products</h2>

<h3>Lorem Ipsum</h3>

<ul>

<li><a href="#nogo1">Integer nonummy neque.</a></li>

<li><a href="#nogo1">Aliquam accumsan.</a></li>

<li><a href="#nogo1">Nulla in sapien eget eros.</a></li>

<li><a href="#nogo1">Nam varius ante et risus.</a></li>

<li><a href="#nogo1">Phasellus at erat id metus.</a></li>

<li><a href="#nogo1">Donec malesuada ultricies.</a></li>

<li><a href="#nogo1">Duis quis purus sit amet.</a></li>

<li><a href="#nogo1">Morbi porta dapibus enim.</a></li>

</ul>

<h3 class="clear">Product Information</h3>

<p>Suspendisse potenti. Donec viverra molestie enim. Fusce fermentum, erat id cursus aliquam, mauris augue volutpat dolor, in interdum purus pede dictum diam. Morbi interdum diam at ligula. Morbi laoreet. Morbi mollis tristique justo. Etiam accumsan fermentum ipsum. Phasellus vestibulum, leo in dapibus ultricies, nisi nulla fermentum tortor, eu lobortis nibh urna ac dui. Aliquam erat volutpat. Curabitur vitae sapien sed libero dictum pellentesque. Praesent quis enim nec tellus congue hendrerit. Ut tellus. Morbi rhoncus elit lobortis libero.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p2"><a href="#nogo" class="menuitem"><i>Services</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="service.jpg" alt="" />

<h2>Services</h2>

<h3>Curabitur eget</h3>

<ul>

<li><a href="#nogo2">Suspendisse potenti.</a><br />Quisque at ante nec lacus cursus malesuada.</li>

<li><a href="#nogo2">Donec viverra molestie enim.</a><br />Sed ac tortor nec augue hendrerit pulvinar.</li>

<li><a href="#nogo2">Pellentesque habitant.</a><br />Nullam rhoncus hendrerit orci.</li>

<li><a href="#nogo2">Vivamus non turpis.</a><br />Sed lacinia egestas mi.</li>

</ul>

<h3 class="clear">Available Services</h3>

<p>Proin scelerisque justo quis ante. Maecenas vehicula orci quis arcu. Nam dictum lectus quis ipsum. In felis. Cras eu lectus. Nam sed est ut orci venenatis faucibus. Ut molestie massa non massa. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Curabitur eget magna a odio vestibulum laoreet. Vivamus faucibus tincidunt massa. Sed a nunc. Quisque varius sagittis libero.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p3"><a href="#nogo" class="menuitem"><i>Latest Information</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="news.jpg" alt="" />

<h2>Latest Information</h2>

<h3>Fusce fermentum</h3>

<ul>

<li><a href="#nogo3">Donec posuere enim a sapien.<br />Malesuada fames ac turpis egestas.</a></li>

<li>Vivamus dignissim tincidunt quam.</li>

<li>Nullam varius vestibulum mauris.</li>

<li>Curabitur faucibus varius dui.<br /><a href="#nogo3">Cras suscipit viverra felis. Nullam diam.</a></li>

<li>Vivamus convallis volutpat nunc.</li>

<li>Sed porttitor dui vel nunc.</li>

</ul>

<h3 class="clear">Latest Product Information</h3>

<p>Nam porttitor congue diam. Donec in mi. Fusce ac neque. Donec quis justo. Nunc non justo quis augue sagittis volutpat. Etiam quis ligula commodo augue tempus pulvinar. Morbi ante arcu, aliquam ut, consequat et, consequat sed, sem. Cras suscipit viverra felis. Nullam diam. Duis eros purus, ornare sit amet, viverra sed, laoreet ac, pede.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p4"><a href="#nogo" class="menuitem"><i>Press Release</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="press.jpg" alt="" />

<h2>Press Release</h2>

<h3>Quisque varius</h3>

<dl>

<dt>11th June 2007</dt>

<dd>In feugiat scelerisque pede.</dd>

<dd>Morbi iaculis eleifend ante.</dd>

<dd>Maecenas fringilla scelerisque erat.</dd>

<dd>Nam <a href="nogo5">accumsan</a>egestas eros.</dd>

</dl>

<h3 class="clear">News and Information</h3>

<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse vitae sem. <a href="nogo5">Class aptent taciti</a>sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Donec ut nunc. <a href="nogo5">In dictum, dui nec vehicula vehicula</a>, neque leo faucibus est, porta vehicula nisi odio eu tellus.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

<li class="page p5"><a href="#nogo" class="menuitem"><i>Contact us</i><!--[if IE 7]><!--></a><!--<![endif]-->

<!--[if lte IE 6]><table><tr><td><![endif]-->

<div>

<em></em>

<img src="contact.jpg" alt="" />

<h2>Contact us</h2>

<h3>Donec condimentum</h3>

<ul>

<li>Phasellus vitae arcu et mauris facilisis ornare.</li>

<li>Nullam ultrices <a href="#nogo5">urna nec erat</a>facilisis faucibus.</li>

<li>Ut cursus posuere eros.</li>

<li>Vestibulum <a href="#nogo5">dapibus</a>tortor eu nisl.</li>

<li>Proin ac mauris non lacus pharetra aliquet.</li>

</ul>

<h3 class="clear">Contact Details</h3>

<p>Praesent vehicula interdum massa. Nunc velit erat, pulvinar vitae, tempor non, porttitor non, ipsum. Nullam venenatis, quam a tincidunt semper, neque velit dictum quam, at mattis mauris mauris a dolor. Aliquam urna. <a href="nogo5">Ut pellentesque dapibus quam.</a>Mauris dapibus dictum felis. Praesent tellus quam, aliquet in, malesuada aliquet, pretium non, eros. Cras aliquam ligula vitae nunc.</p>

</div>

<!--[if lte IE 6]></td></tr></table></a><![endif]-->

</li>

</ul>

</div>

<br>

<br>

<br>

<div>

</div>

</body>

</html>

<script language=javascript ></script>

我的也是,我的是在首页上显示完全正常的导航,到了宝贝详情页面就像完全没有调用到我的CSS一样,同样求解什么原因~

把你的那一段的代码加在<div class=tb-shop></div>中间试试,我的也是在内页没显示,我就是这个方法弄好的~

<!DOCTYPE html> 2 <html lang="en"> 3 <head> 4     <meta charset="UTF-8"> 5     <title>Document</title> 6     <style> 7         ul{ 8             list-style: none 9         }10         .nav>li{11             float: left12         }13         ul a{14             display: block15             text-decoration: none16             width: 100px17             height: 50px18             text-align: center19             line-height: 50px20             color: white21             background-color: #2f3e4522         }23         .nav>li:first-child a{24             border-radius: 10px 0 0 10px25         }26         .nav>li:last-child a{27             border-radius: 0 10px 10px 028         }29         .drop-down{30             /*position: relative*/31         }32         .drop-down-content{33             padding: 034             display: none35             /*position: absolute*/36         }37         38         h3{39             font-size: 30px40             clear: both41         }42         .drop-down-content li:hover a{43             background-color:red44         }45         .nav .drop-down:hover .drop-down-content{46             display: block47         }48 </style>49 </head>50 <body>51     <ul class="nav">52         <li><a href="#">下拉菜单</a></li>53         <li class="drop-down"><a href="#">下拉菜单</a>54             <ul class="drop-down-content">55                 <li><a href="#">我是1</a></li>56                 <li><a href="#">我是2</a></li>57                 <li><a href="#">我是3</a></li>58             </ul>59             </li>60         <li><a href="#">下拉菜单</a></li>61         <li><a href="#">下拉菜单</a></li>62         <li><a href="#">下拉菜单</a></li>63     </ul>64     <h3>我是测试文字</h3>65 </body>66 </html>