javascript - Submenu with jquery is not working as it should -
my process:
i´m using jquery hover effect, when hover mouse in list item want find submenu , use fadetoggle effect.
its like, when hover mouse children list items , if displayed hide if hidden display.
and use stop method avoid strange effects if people pass fast on menu on , on again.
my issue:
i think thought correctly unfortunately i´m having issue.
the submenu items appear behind other elements, behind #banner-container, submenu items not visible.
i have tried play positions, far without success, know how solve problem?
my jsfiddle can see problem:
http://jsfiddle.net/jcak/9ecnl/6/
html:
<nav id="menu"> <ul> <li><a href="index.html">home</a> <ul> <li><a href="#">link 1</a></li> <li><a href="#">link 2</a></li> <li><a href="#">link 3</a></li> <li><a href="#">link 4</a></li> </ul> </li> <li><a href="procuts.html">procuts</a> <ul> <li><a href="#">link 1</a></li> <li><a href="#">link 2</a></li> <li><a href="#">link 3</a></li> <li><a href="#">link 4</a></li> </ul> </li> <li><a href="#">about</a></li> <li><a href="#">contacts</a></li> </ul> </nav>
jquery:
$('li').hover(function(){ $(this).find('ul>li').stop().fadetoggle(300); });
css:
#menu ul li ul li {display:none;} #menu-container { background:green; width:100%; height:46px; float:left; z-index:7; } #menu { width:960px; height:auto; margin:0 auto 0 auto; } #menu ul { list-style-type:none; } #menu ul li { float:left; height:46px; line-height:46px; font-weight:300; } #menu ul li { text-decoration:none; color:#ccc; display:block; margin-right:5px; height:46px; line-height:46px; padding:0 5px 0 5px; font-size:20px; } #menu ul li a:hover { color:#fff; }
you want this, right?
your javascript fine, forgot add in jquery library in jsfiddle options. put in css make submenus displayed little better.
#menu ul li { display: inline-block; float:left; height:46px; position: relative; line-height:46px; font-weight:300; } #menu ul li { text-decoration:none; color:#ccc; display:block; margin-right:5px; height:46px; line-height:46px; padding:0 5px 0 5px; font-size:20px; } #menu ul li a:hover { color:#fff; } #menu ul li ul { position: absolute; left: 0; -webkit-padding-start: 0; width: 300px; } #menu ul li ul li { color:#fff; }
Comments
Post a Comment