Dropdowns
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They’re made interactive with the included Bootstrap dropdown JavaScript plugin.
Class | Description | Syntax |
---|---|---|
Divider | Creates a horizontal list to divide dropdown menu | .dropdown |
Header | Adds header section inside the dropdown list. | .dropdown-header |
Disable and active items | Used to diable and enable list of items. | .active|disabled |
Dropdown position | Sets the position of dropdown list. | .dropright|dropleft |
Dropdown Menu Right Aligned | Right aligns the dropdown menu. | .dropdown-menu-right |
Dropup | Expands the menu list upwards. | .dropup |
Dropdown text | Adds plain text in the dropdown menu list. | .dropdown-item-text |
Grouped Buttons with a Dropdown | Creates a group of buttons in the dropdown list. | .btn-group |
Split Button Dropdowns | Splits the dropdown buttons. | .dropdown-toggle-split |
Vertical Button Group Dropdown List | Creates a vertical button group. | .btn-group-vertical |
Example Code:
<!DOCTYPE html>
<html>
<head>
<!-- Load Bootstrap -->
<link rel="stylesheet"
href=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css"
integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I"
crossorigin="anonymous">
<script src=
"https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
integrity=
"sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous">
</script>
<script src=
"https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js"
integrity=
"sha384-oesi62hOLfzrys4LxRF63OJCXdXDipiYWBnvTl9Y9/TRlw5xlKIEHpNyvvDShgf/"
crossorigin="anonymous">
</script>
</head>
<body style="text-align: center;">
<div class="container mt-3" style="width: 700px;">
<h1 style="color: green;">
w3wiki
</h1>
<!-- Dropdown position-->
<div class="dropdown dropright">
<button type="button" class="btn btn-success dropdown-toggle"
data-toggle="dropdown">
Select Subjects
</button>
<div class="dropdown-menu">
<!-- header and divider -->
<strong class="dropdown-header ">
CS Subjects
</strong>
<a class="dropdown-item" href="#">
Data Structure
</a>
<a class="dropdown-item" href="#">
Algorithm
</a>
<a class="dropdown-item" href="#">
Operating System
</a>
<!--Active and Disabled -->
<a class="dropdown-item active" href="#">
Computer Networks
</a>
<div class="dropdown-divider "></div>
<strong class="dropdown-header">
Other Subjects
</strong>
<a class="dropdown-item" href="#">
Physics
</a>
<a class="dropdown-item disabled" href="#">
Mathematics
</a>
<a class="dropdown-item" href="#">
Chemistry
</a>
</div>
</div>
</div>
</body>
</html>
Bootstrap Cheat Sheet – A Basic Guide to Bootstrap
Bootstrap is a free, open-source, potent CSS framework and toolkit used to create modern and responsive websites and web applications. It is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. Nowadays, websites are perfect for all browsers and all sizes of screens.