带有下拉菜单右侧类的下拉菜单与右侧不对齐

时间:2021-10-11 19:57:09

I have the following navbar structure ({{ current_user.username }} is from my templating system):

我有以下导航栏结构({{current_user.username}}来自我的模板系统):

<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
    <!-- navbar items -->
</ul>
<div class="dropdown show">
    <a class="dropdown-toggle" style="color: inherit" href="#" id="dropdownLink" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
        <i class="fa fa-user" aria-hidden="true"></i>
        {{ current_user.username }}
    </a>
    <ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dropdownLink">
        <li><a class="dropdown-item" href="#">Profile</a></li>
        <!-- etc -->
    </ul>
</div>

The dropdown part is aligned to the right of the screen, but clicking on it displays the dropdown menu going off the right of the screen, which the dropdown-menu-right class is supposed to prevent. Any ideas?

下拉部分与屏幕右侧对齐,但点击它会显示屏幕右侧的下拉菜单,下拉菜单右侧的类应该阻止。有任何想法吗?

Minimal Codepen: https://codepen.io/Majora320/pen/jGwNrE

最小的Codepen:https://codepen.io/Majora320/pen/jGwNrE

1 个解决方案

#1


1  

If you add the style

如果添加样式

right: 0

to

 .dropdown-menu

style rule... it will do what you want.

风格规则......它会做你想要的。

#1


1  

If you add the style

如果添加样式

right: 0

to

 .dropdown-menu

style rule... it will do what you want.

风格规则......它会做你想要的。