Need help making dropdown on navbar collapse

Need help making dropdown on navbar collapse
0

#1

Hello, I’m trying to make the dropdown menu in my navbar collapse but it does not seem to be working. I have tried putting the JQuery CDN before the Bootstrap on the resources part of CodePen but that does not seem to work. Any help would be much appreciated thanks!


#2

There seems to be a problem with the settings in Codepen. One of the Bootstrap choices under Javascript is actually the cdn for bootstrap CSS, not JS. You had selected that one so you did not have the benefit of the .js library that comes with Bootstrap (Actually I think that might be a minor bug - why is a css file under the javascript menu anyways??)

Select the choice that has 4.1.3/js in the path and you’re good to go
image


#3

OMG thank you so much. Now I just Have to figure out how to align the dropdown to the center


#4

You’re welcome. That must have been frustrating.

I think your hierarchy of elements is different than the example on the documentation page. Their menus are usually in <li> tags

I usually just copy the example code and delete what I don’t want. Then I customize what is remaining. Sounds lazy but the library code is looking for specific elements of specific classes and it is hard to tell what can and cannot be left out.


#5

Just add position: relative to your .navbar-collapse class, since the dropdown ul already has an absolute position, it fits into its parent