Avatar of Melody Scott
Melody Scott
Flag for United States of America asked on

Dropdown in Bootstrap nav not working

gooddiabetesdiet.com/responsive/index2.html

on that page, I wanted to shorten the menu by adding a dropdown. As far as I can tell, I've done it correctly, and the top portion with the caret is there, but if I click on it, no dropdown appears. It seems that maybe I don't have the right CSS?

Thanks for your help.
CSSWeb DevelopmentHTML

Avatar of undefined
Last Comment
Melody Scott

8/22/2022 - Mon
COBOLdinosaur

You cannot fire a dropdown with a click event when the element being clicked is a link the link has priority.

if you want the dropdown to display either take the link off the top element of the menu or user hover with something like:

.dropdown-toggle:hover dropdown-menu{display:block;}

Cd&
Melody Scott

ASKER
Ok, will try that. This is the exact code given here: http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-dropdowns.php They have:

            <li class="dropdown">

                <a href="#" data-toggle="dropdown" class="dropdown-toggle">Messages <b class="caret"></b></a>

                <ul class="dropdown-menu">

                    <li><a href="#">Inbox</a></li>

                    <li><a href="#">Drafts</a></li>

                    <li><a href="#">Sent Items</a></li>

                    <li class="divider"></li>

                    <li><a href="#">Trash</a></li>

                </ul>

            </li>
Melody Scott

ASKER
OK, I changed it to this, same problem:

    <li data-toggle="dropdown" class="dropdown dropdown-toggle btn btn-green">Diabetic Meals <b class="caret"></b></li>
                    <ul role="menu mainmenu" class="dropdown-menu">
                        <li><a href="living-with-diabetes.html">Living with Diabetes</a></li>
                        <li><a href="nutrition.html">Diabetic Nutrition</a></li>
                             <li><a href="good-diabetic-diet-news.html">Diabetic News</a></li>
                    </ul>
                </li>
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
COBOLdinosaur

I don't know how but you have now got 5 validation errors in the page right where the menu is and they are serious structural errors.  I can't make it any simpler or straight forward then the styling I gave you. Copy and paste from an example does not guarantee anything except that is works on the page where you found it.

Basically bootstrap has turned what would be a 10 minute fix in ordinary code into a major operation.

Take a look at my dropdown menu page and see if it helps seeing how to do it without all the bloated bootstrap junk in the way.

Cd&
Melody Scott

ASKER
Sorry, doesn't help me. I'm just not understanding it. I tried what you said to do, and it didn't work, so I'm not sure where to go from here.
COBOLdinosaur

I'm not sure where to either Mel.  I suspect that somewhere buried in the bloated bottscrap mess there is something that is either overriding or preventing the normal cascade.  The DOM has probably been damaged by the BS jquery, though it could be that one of the others is creating some kind of conflict.

The best approach at this point is probably to go through the jquery code and see if you can find the function that is breaking it.  Hopefully when you find it, you will be able to fix it without breaking something else.

Cd&
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
David Johnson, CD

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Melody Scott

ASKER
Thanks, that almost works!! I'll work on the one item that's too high, but we're close, thanks!
Melody Scott

ASKER
Thanks! That works great!