drop down BOOTSTRAP code example

Example 1: create a dropdown in html bootstrap

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown
  </button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenu2">
    <button class="dropdown-item" type="button">Action</button>
    <button class="dropdown-item" type="button">Another action</button>
    <button class="dropdown-item" type="button">Something else here</button>
  </div>
</div>

Example 2: bootstrap 4 dropdown

<div class="dropdown">
  <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown button
  </button>
  <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
  </div>
</div>

Example 3: bootstrap dropdown

<!-- Bootstrap 5 Dropdown -->
<div class="dropdown">
   <button
      class="btn btn-secondary dropdown-toggle"
      type="button"
      id="dropdownMenuButton1"
      data-bs-toggle="dropdown"
      aria-expanded="false"
   >
      Dropdown button
   </button>
   <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
      <li><a class="dropdown-item" href="#">Action</a></li>
      <li><a class="dropdown-item" href="#">Another action</a></li>
      <li><a class="dropdown-item" href="#">Something else here</a></li>
   </ul>
</div>

Example 4: dropdown bootstrap

<div class="dropdown show">
  <a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
    Dropdown link
  </a>

  <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
  </div>
</div>

Example 5: dropdown forms in bootstrap

<li class="dropdown">
         <a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown            

         <b class="caret"></b></a>
         <ul class="dropdown-menu">
           <li><a href="#"><form role="form">
<div class="form-group">
  <label for="sel1">Select list (select one):</label>
  <select class="form-control" id="sel1">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
  </select>
  <br>
  <label for="sel2">Mutiple select list (hold shift to select more than one):</label>
  <select multiple class="form-control" id="sel2">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
  </select>
</div>

Example 6: bootstrap dropdown

.dropdown
Add a simple dropdown menu with buttons.
<div class=”dropdown”>
 <button class=”btn btn-secondary dropdown-toggle”
 type=”button” id=”dropdownMenu1” data-toggle=”dropdown”
 aria-haspopup=”true” aria-expanded=”false”>
 Dropdown
 </button>
 <div class=”dropdown-menu” aria-labelledby=”dropdownMenu1”>
 <a class=”dropdown-item” href=”#!”>Action</a>
 <a class=”dropdown-item” href=”#!”>Another action</a>
 </div>
</div>
.dropdown-toggle-split
Create split button dropdowns with proper spacing around the dropdown caret.
<div class=”btn-group”>
 <button type=”button” class=”btn btn-secondary”>Dropdown</button>
 <button type=”button” class=”btn btn-secondary dropdown-toggle dropdown-togglesplit” data-toggle=”dropdown” aria-haspopup=”true” aria-expanded=”false”>
 <span class=”sr-only”>Toggle Dropdown</span>
 </button>
 <div class=”dropdown-menu”>
 <a class=”dropdown-item” href=”#!”>Action</a>
 <a class=”dropdown-item” href=”#!”>Another action</a>
 </div>
</div>
.dropup
Did you know that you can style a menu coming up rather than down? Now you do!
<!-- Default dropup button -->
<div class=”btn-group dropup”>
 <button type=”button” class=”btn btn-secondary dropdown-toggle” datatoggle=”dropdown” aria-haspopup=”true” aria-expanded=”false”>
 Dropup
 </button>
 <div class=”dropdown-menu”>
 <!-- Dropdown menu links -->
 </div>
</div>
.dropright
Provide the menu to the right of the button.
 <!-- Default dropright button -->
<div class=”btn-group dropright”>
 <button type=”button” class=”btn btn-secondary dropdown-toggle” datatoggle=”dropdown” aria-haspopup=”true” aria-expanded=”false”>
 Dropright
 </button>
 <div class=”dropdown-menu”>
 <!-- Dropdown menu links -->
  </div>
</div>
.dropleft
...And you can also display the menu on the left.
<!-- Default dropleft button -->
<div class=”btn-group dropleft”>
 <button type=”button” class=”btn btn-secondary dropdown-toggle” datatoggle=”dropdown” aria-haspopup=”true” aria-expanded=”false”>
 Dropleft
 </button>
 <div class=”dropdown-menu”>
 <!-- Dropdown menu links -->
 </div>
</div>
.dropdown-item-text
Add non-interactive dropdown items to your menu.
<div class=”dropdown-menu”>
 <span class=”dropdown-item-text”>Plain text</span>
 <a class=”dropdown-item” href=”#”>Clickable action</a>
 <a class=”dropdown-item” href=”#”>Another action</a>
 <a class=”dropdown-item” href=”#”>Whatever else you need</a>
</div>
.dropdown-item disabled
You can also choose to disable any menu item(s).
<div class=”dropdown-menu”>
 <a class=”dropdown-item” href=”#”>Active link</a>
 <a class=”dropdown-item disabled” href=”#”>Disabled link</a>
 <a class=”dropdown-item” href=”#”>One more link</a>
</div>
.dropdown-divider
Add a simple divider between menu elements to draw extra attention.
<div class=”dropdown-divider”></div>
.dropdown-menu-right
Align the entire menu to the right
<div class=”btn-group”>
 <button type=”button” class=”btn btn-secondary dropdown-toggle” datatoggle=”dropdown” aria-haspopup=”true” aria-expanded=”false”>
 This dropdown’s menu is right-aligned
 </button>
 <div class=”dropdown-menu dropdown-menu-right”>
 <button class=”dropdown-item” type=”button”>Action</button>
 <button class=”dropdown-item” type=”button”>Another action</button>
 <button class=”dropdown-item” type=”button”>Something else here</button>
 </div>
</div>

Tags:

Css Example