0
0
Bootsrapmarkup~10 mins

Dropdown directions (up, left, right) in Bootsrap - Browser Rendering Trace

Choose your learning style9 modes available
Render Flow - Dropdown directions (up, left, right)
Read <div class='dropdown'>
Create dropdown container node
Read <button class='dropdown-toggle'>
Create button node
Read <ul class='dropdown-menu'>
Create menu node
Apply direction class (dropup, dropstart, dropend)
Position menu accordingly
Render button and menu visually
The browser reads the dropdown HTML structure, creates nodes for the container, button, and menu. Then Bootstrap's direction classes adjust the menu's position relative to the button before rendering.
Render Steps - 4 Steps
Code Added:<div class="dropdown"> <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</button> <ul class="dropdown-menu"> <li><a class="dropdown-item" href="#">Action</a></li> </ul> </div>
Before
[ ] (empty page)
After
[Dropdown Button]
(Click to open menu below)

[ ] (menu hidden)
Added a basic dropdown container with a button and hidden menu below it.
🔧 Browser Action:Creates DOM nodes and applies default Bootstrap dropdown styles.
Code Sample
This code creates a dropdown menu that opens upwards (dropup). The CSS positions the menu above the button. Similar classes dropstart and dropend position the menu to the left or right.
Bootsrap
<div class="dropdown dropup">
  <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
    Dropup
  </button>
  <ul class="dropdown-menu">
    <li><a class="dropdown-item" href="#">Action</a></li>
    <li><a class="dropdown-item" href="#">Another action</a></li>
  </ul>
</div>
Bootsrap
.dropup .dropdown-menu {
  top: auto;
  bottom: 100%;
  margin-bottom: 0.125rem;
}
.dropstart .dropdown-menu {
  top: 0;
  right: 100%;
  margin-right: 0.125rem;
}
.dropend .dropdown-menu {
  top: 0;
  left: 100%;
  margin-left: 0.125rem;
}
Render Quiz - 3 Questions
Test your understanding
After applying the 'dropup' class (render_step 2), where does the dropdown menu appear relative to the button?
AAbove the button
BBelow the button
CTo the left of the button
DTo the right of the button
Common Confusions - 2 Topics
Why does the dropdown menu sometimes appear off-screen when using dropstart or dropend?
Because the menu opens to the left or right, if the button is near the edge of the viewport, the menu can overflow outside the visible area.
💡 Place dropstart menus away from the left edge and dropend menus away from the right edge to keep menus visible.
Why doesn't the dropdown menu open above the button when I add 'dropup' class but the menu still appears below?
The 'dropup' class must be added to the dropdown container, not the button. Also, Bootstrap's JavaScript must be loaded to handle positioning.
💡 Always add direction classes to the container div with class 'dropdown'.
Property Reference
ClassMenu PositionCSS PositioningVisual EffectCommon Use
dropdownBelow buttontop: 100%; left: 0;Menu opens below buttonDefault dropdown
dropupAbove buttonbottom: 100%; left: 0;Menu opens above buttonMenus that open upward
dropstartLeft sidetop: 0; right: 100%;Menu opens to the leftSide menus on left
dropendRight sidetop: 0; left: 100%;Menu opens to the rightSide menus on right
Concept Snapshot
Bootstrap dropdown menus open by default below the button. Use 'dropup' to open menu above. Use 'dropstart' to open menu on the left. Use 'dropend' to open menu on the right. Direction classes adjust CSS positioning of the menu. Place menus carefully near viewport edges to avoid clipping.