You can remove the JavaScript code that positions the dropdown and just define it in the CSS. If you position .dropdown
relatively, .dropdown_content
will be positioned relative to it's parent, which makes positioning easy:
.dropdown {
...
position: relative;
}
.dropdown .dropdown_content {
...
top: 100%;
left: 0;
margin: 5px 0;
}
Remove these lines of JavaScript:
var o = $(this).parent().find('.dropdown_button').offset();
var h = $(this).parent().find('.dropdown_button').height();
$(this).parent().find('.dropdown_content').css({'top':(o.top+h-1),'left':o.left});
(That is where your inline top
and left
values are coming from.)
Also, remove overflow: hidden
from your body
style definition.
Working demo: http://jsfiddle.net/gilly3/EA6LS/2/
I also usually think it's a good idea to uncheck "Normalized CSS" in jsfiddle. When debugging CSS, that can lead to confusing results.
While you're at it... that JavaScript can be simplified: http://jsfiddle.net/gilly3/EA6LS/4/