5

I have many subcategories to be displayed in home page, but it is vertically too long,, i want to make it scroll on hover. what changes need to be done in css or other files, please guide me script which is responsive

reference:https://css-tricks.com/examples/LongDropdowns/ i want scolling of list as in referred website mentioned above

subcategories with long dropdown

1 Answer 1

1
add height and overflow scroll styke.css line 3529 .nav-primary li.level0 ul { background: none repeat scroll 0 0 #fbfbfb; border: 1px solid #cccccc; display: none; height: 50px; left: 0; overflow: scroll; padding-left: 10px; padding-right: 10px; position: absolute; top: 30px; width: 250px; z-index: 10; } 

this jquery function for dropdown scroll adjust it according to your classes.

 <script> var maxHeight = 100; jQuery.noConflict(); jQuery(function(){ jQuery(".nav-primary > li").hover(function() { var jQuerycontainer = jQuery(this), jQuerylist = jQuerycontainer.find("ul"), jQueryanchor = jQuerycontainer.find("a"), height = jQuerylist.height() * 1.1, // make sure there is enough room at the bottom multiplier = height / maxHeight; // needs to move faster if list is taller // need to save height here so it can revert on mouseout jQuerycontainer.data("origHeight", jQuerycontainer.height()); // so it can retain it's rollover color all the while the dropdown is open jQueryanchor.addClass("hover"); // make sure dropdown appears directly below parent list item jQuerylist .show() .css({ paddingTop: jQuerycontainer.data("origHeight") }); // don't do any animation if list shorter than max if (multiplier > 1) { jQuerycontainer .css({ height: maxHeight, overflow: "hidden" }) .mousemove(function(e) { var offset = jQuerycontainer.offset(); var relativeY = ((e.pageY - offset.top) * multiplier) - (jQuerycontainer.data("origHeight") * multiplier); if (relativeY > jQuerycontainer.data("origHeight")) { jQuerylist.css("top", -relativeY + jQuerycontainer.data("origHeight")); }; }); } }, function() { var jQueryel = jQuery(this); // put things back to normal jQueryel .height(jQuery(this).data("origHeight")) .find("ul") .css({ top: 0 }) .hide() .end() .find("a") .removeClass("hover"); })}); // Add down arrow only to menu items with submenus // jQuery(".nav-primary > li:has('ul')").each(function() { // jQuery(this).find("a:first").append("<img src='images/down-arrow.png' />"); // }); </script> 
8
  • I don want to add scrolling bar through overflow scroll,, i want just to scroll on hover of subcategories or atleast just display arrows to scroll Commented Sep 28, 2015 at 4:45
  • scoll bar doesnt look good for homepage display Commented Sep 28, 2015 at 4:47
  • 1
    css-tricks.com/custom-scrollbars-in-webkit follow this to design the scroll bar Commented Sep 28, 2015 at 4:49
  • I want something to display like this: css-tricks.com/examples/LongDropdowns Commented Sep 28, 2015 at 4:55
  • 1
    i added js in answer adjust the class according to it Commented Sep 28, 2015 at 4:57

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.