Jquery Dropdown Menu: The Dropdown works fine but animation doesn't work, help and Thanks -
http://jsfiddle.net/jerrypeng0112/ahm7q1bq/ i've spent while on problem, way make work set specific width
`<body> <header id="header"> <nav> <ul id="main"> <li><a href="#">home</a> </li> <li> <a href="#">about</a> <ul class="hidden"> <li><a href="#">about 1</a> </li> <li><a href="#">about 2</a> </li> <li><a href="#">about 3</a> </li> </ul> </li> <li> <a href="#">services</a> <ul class="hidden"> <li><a href="#">services 1</a> </li> <li><a href="#">services 2</a> </li> <li><a href="#">services 3</a> </li> </ul> </li> <li> <a href="#">history</a> <ul class="hidden"> <li><a href="#">the history of site</a> </li> <li><a href="#">the history of web</a> </li> <li><a href="#">the history of whatever</a> </li> </ul> </li> <li><a href="#">contact</a> </li> </ul> </nav> </header> </body>`
this css
body { margin:0; padding:0; height:1000px; background: #39a; font-family:arial; } header { z-index:2; position: fixed; width: 100%; height: 60px; background: #222; } nav { float:left; } nav ul { list-style-type:none; margin:0; padding:0; } nav ul li { display:inline-block; float:left; } nav ul li { display:block; width:80px; height:60px; text-align:center; text-decoration:none; line-height:60px; color:white; background:#404040; } nav ul li a:hover { background:darkgray; } nav ul li:hover ul { display:block; } nav ul li:hover ul { background:#404040; color:white; height:60px; line-height:60px; } ul.hidden { display:none; position:absolute; border-top:white solid 2px; } ul.hidden li { display:block; float:none; } ul.hidden li { width:auto; min-width:80px; padding:0 20px; } ul.hidden li a:hover { background:darkgray; }
this script
$(document).ready(function () { var width = $(window).width(); if (width > 800) { $('ul li').hover(function () { $('ul.hidden'.this).filter(':not(:animated)').slidedown(500); }, function () { $('ul.hidden' this).fadeout(500); }); } });
http://jsfiddle.net/rcz0zt0v/20/
if you're going use jquery animation don't need :hover define block
$(document).ready(function () { $('ul .dropdown').on('mouseenter', function(e){ $(this).find('ul').slidedown(200); }).on('mouseleave', function(){ $(this).find('ul').slideup(100); }); });
Comments
Post a Comment