scrolling sub menu items

How we can manage long dropdown with sub-menu items? Solution: See this Scrolling Sub Menu Items For Long Dropdown Menu, Navbar With jQuery & CSS.

Previously I have shared many navbar related programs, but this is a solution for the long dropdown menu. Basically, we all use a dropdown menu but sometimes the sub-menu items are large in quantity, then we get trouble to manage them. When the dropdown becomes very long in height because of many sub-menu items, then you have to scroll down the whole page for seeing the left items. Suppose, we don’t have a sticky navbar and the dropdown based on hover then the user can’t access all the items. Because, if the user scrolls down the page for seeing the left items then the navbar will go upside and they can’t hover on it from bottom or downside.

Today you will learn to create a navbar with jQuery and CSS for managing long dropdowns. Basically, there is a navbar with 4 menu items and inside the menu, there are some sub-menu items that will visible on hover. On the first menu link, there are many sub-items, the second one has lesser than the first one and the other two have the number of sub-items with same order. But there is fix or max size of the dropdown, that does not matter the menu contains how many sub-items. The main feature is you will hover on the last sub-item then it will automatically scroll down.

So, Today I am sharing Scrolling Sub Menu Items For Long Dropdown Menu. There I have used jQuery for creating this program which is a JS library, that’s why I am putting this post in the JavaScript category. All the styles are based on simple CSS, there is no UI library. This navbar program has not responsive design because it is only an example of how we can manage long dropdowns.

If you are thinking now how this long navbar actually is, then see the preview given below.

Preview Of jQuery and CSS Solution For Long Dropdown Menu

See this video preview to getting an idea of how this scrollable submenu looks like.

Live Demo

Now you can see this visually, also you can see it live by pressing the button given above. If you like this, then get the source code of its.

You May Also Like:

Scrolling Sub Menu Items For Long Dropdown Menu Source Code

Before sharing source code, let’s talk about it. First, I have created the layout using HTML </nav> tag and placed a list inside it for creating the menu items. All the menu and sub-menus are based on HTML list <ul> & <li> tags and for the sub-menu items I have placed another list inside the menu list items.

Now using CSS I have placed all the elements in the right place, as you can see in the preview. I gave style to the elements by giving size, position, color, margin, padding, etc. There I have used a google font in the program for good UI, and also you can see in hover effect which is change background color on mouseover.

jQuery handling the main part or feature of the program, which is scrollable sub menu items. The dropdown has a max-height but sub-items will scroll down or up on mouse move. For creating that feature I have used .mousemove function (info) command and also used if{} else{} statements. JS codes are a little complicated I can’t explain here, but you will understand after getting the codes.

For creating this program you have to create 3 files. First one for HTML, second for CSS, and the third for JavaScript. Follow the steps to creating this without any error.

index.html

Create an HTML file named ‘index.html‘ and put these codes given below.

style.css

Now create a CSS file named ‘style.css‘ and put these codes given here.

function.js

The final step, create a JavaScript file named ‘function.js‘ and put the codes.

That’s It. Now you have successfully created Scrolling Sub Menu Items For Long Dropdown Menu, Program With jQuery & CSS. If you have any doubt or question comment down below.

Thanks For Visiting, Keep Visiting.

LEAVE A REPLY

Please enter your comment!
Please enter your name here