0
0
Bootsrapmarkup~30 mins

Dropdown menu alignment in Bootsrap - Mini Project: Build & Apply

Choose your learning style9 modes available
Dropdown Menu Alignment with Bootstrap
📖 Scenario: You are building a website navigation bar. You want to add a dropdown menu that opens aligned to the right side of the button, so it looks neat and fits well on the page.
🎯 Goal: Create a Bootstrap dropdown menu that is aligned to the right side of its toggle button.
📋 What You'll Learn
💡 Why This Matters
🌍 Real World
Dropdown menus are common in website navigation bars and user interfaces to organize links and actions neatly.
💼 Career
Knowing how to use Bootstrap dropdowns and align menus is useful for front-end web developers building responsive and user-friendly websites.
Progress0 / 4 steps
1
Create the basic dropdown button and menu
Write the HTML code to create a Bootstrap dropdown button with the text Menu and a dropdown menu containing three items: Home, About, and Contact. Use the classes dropdown, btn, btn-primary, dropdown-toggle, and dropdown-menu as needed.
Bootsrap
Need a hint?

Remember to use the dropdown-toggle class on the button and the dropdown-menu class on the menu container.

2
Add a helper class to align the dropdown menu
Add the Bootstrap class dropdown-menu-end to the <ul> element with class dropdown-menu to align the dropdown menu to the right side of the toggle button.
Bootsrap
Need a hint?

The class dropdown-menu-end moves the dropdown menu to align on the right side.

3
Add Bootstrap CSS and JS links for functionality
Add the Bootstrap 5 CSS link inside the <head> and the Bootstrap 5 JavaScript bundle with Popper script before the closing </body> tag. Use the official Bootstrap 5 CDN URLs for CSS and JS bundle.
Bootsrap
Need a hint?

Include the Bootstrap CSS in the <head> and the JS bundle before </body>.

4
Wrap the dropdown in a responsive container
Wrap the dropdown <div> inside a Bootstrap container <div class="container mt-3"> to add spacing and responsiveness.
Bootsrap
Need a hint?

Use a Bootstrap container with margin top to add spacing and responsiveness.