Boot Screen 4 Navbar Dropdown Right

As you see in the picture below, when I click on the bell icon, a drop-down menu appears in the lower right corner of the icon. I want this drop-down menu to be displayed at the bottom left and not at the bottom right. What should I do?

enter image description here

If you want to see my code, it is written using php :

 function navigation(){ $output = ""; $icons = ["user","bell","envelope","commenting"]; $rows = [2,5,5,5]; for ($i=0; $i < count($icons) ; $i++) { $output .= '<div class="dropdown">'; $output .= '<a class="nav-item nav-link" data-toggle="dropdown">'; $output .= '<i class="fa fa-'.$icons[$i].'"></i></a>'; $output .= '<div class="dropdown-menu text-right">'; for ($j=0; $j < $rows[$i] ; $j++) { $output .= '<a href="#" class="dropdown-item">'.($j+1).'</a>'; } $output .= '</div>'; $output .= '</div>'; } return $output; } 

And then this output will be displayed in the html file:

 <nav class="navbar"> <div class="container"> <div class="navbar-nav d-flex flex-row"> <?= navigation() ?> </div> </div> </nav> 
+15
php drop-down-menu twitter-bootstrap-4 bootstrap-4
May 09 '17 at 10:23
source share
3 answers

Use the dropdown-menu-right class ..

  <div class="dropdown-menu dropdown-menu-right text-right"> <a class="dropdown-item" href="#">Link</a> <a class="dropdown-item" href="#">Link</a> <a class="dropdown-item" href="#">Link</a> </div> 

http://codeply.com/go/6Mf9aK0P8G

+33
May 09 '17 at 11:02
source share

Update for Bootstrap4-Beta strong>:

Since there is an error in bootstrap4 beta , I had to add

 .dropdown-menu-right { right: 0; left: auto; } 

for it to work.

+17
Aug 17 '17 at 9:40 on
source share

.dropdown-menu-right class has a different behavior if it is inside a .navbar . You can read "Heads up" in the docs here:

https://getbootstrap.com/docs/4.0/components/dropdowns/#menu-alignment

Actually, to solve, I use this class:

 .navbar .dropdown-menu-right { right: 0; left: auto; } 
+4
Mar 20 '18 at 11:56
source share



All Articles