Skip to content
Advertisement

Responsive navbar with dropdown not working

I am working on creating a responsive navbar that has a dropdown in it. Below is my code:

I have the CSS code and media queries inline for testing purpose. So it might look lengthy.

JavaScript

The menu contains the Home logo image at the left and 4 menu items on the right.

After the active ‘home’ link is the ‘Programs’ drop-button that should have a dropdown ‘Success’ underneath it. This dropdown is not loading correctly and the design is distorted. Any help to fix this?

Advertisement

Answer

You don’t need your dropdown button to be a div tag, it should be a button tag.

So change

<div class="dropbtn"><a href="#">Programs</a></div>

to

<button class="dropbtn"><a style="padding: 0px" href="#">Programs</a></button>

This should the drop-down load correctly and inline with the other items in the navbar. Hopefully this helps you get on the right track without changing most of your original code.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement