From the course: Bootstrap 4 Essential Training

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Add a dropdown to navigation

Add a dropdown to navigation - Bootstrap Tutorial

From the course: Bootstrap 4 Essential Training

Start my 1-month free trial

Add a dropdown to navigation

- [Instructor] Although dropdowns are technically a separate component, they're used very often in menus. So I'm going to show you how to add them inside a menu element. So, a dropdown requires a container, just like a lot of other elements to work. And so, you'll need to create something that has a class of dropdown. This is usually a div, or it could be on a list item if you're using a navigation that uses list items. I personally prefer to do my navigation just with anchor tags, so I'm going to show you an example like that. And then, this container is used to align the dropdown to the proper item in the navigation. There's also a dropdown-toggle class, and that is added on the link in order to get a little triangle to indicate that this element has a dropdown in it. Now finally, dropdowns can be activated in one of two ways. You could do it through JavaScript or by using a data attribute, and this attribute is called data-toggle, and you set it to dropdown. Bootstrap currently…

Contents