[英]display bootstrap dropdown-menu to orient the list to the left instead of right
I have an issue with the button dropdown from Bootstrap-Twitter 3. 我对Bootstrap-Twitter 3的按钮下拉有问题。
HTML HTML
<div class="input-group">
<input type="text" class="form-control">
<!-- Split button -->
<div class="input-group-btn">
<button type="button" class="btn btn-danger">Action</button>
<button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
In the JSFiddle above, you can see an input stick with a dropdown button at its right. 在上面的JSFiddle中,您可以在右侧看到一个带有下拉按钮的输入框。
The problem is that the list of the dropdown button is displayed in a way that the list is cutted (the viewport should not expand itself, however this is what happens). 问题是下拉按钮的列表以切割列表的方式显示(视口不应自行扩展,但这就是发生的情况)。
Question 题
How can I tell this element to display the list from the right to the left (reverse of the current behaviour) ? 如何告诉此元素从右到左显示列表(与当前行为相反)?
From the documentation : 从文档 :
By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent.
默认情况下,下拉菜单会自动从其父级的顶部和左侧100%定位。 Add
.dropdown-menu-right
to a.dropdown-menu
to right align the dropdown menu.将
.dropdown-menu-right
添加到.dropdown-menu
右键对齐下拉菜单。
<ul class="dropdown-menu dropdown-menu-right">
<!-- your li elements... -->
</ul>
Try Use : 尝试使用:
class="dropdown-menu pull-right"
As you can see here : Updated Fiddle 正如你在这里看到的: 更新了小提琴
This will ensure the dropDown
menu is pulling to the right, which gives it float:right!important
. 这将确保
dropDown
菜单向右拉,这使它float:right!important
。
This will ensure it's not hidden behind. 这将确保它不会隐藏在后面。
EDIT : Rory McCrossan's answer is the recommended solution for this question 编辑 : Rory McCrossan的答案是这个问题的推荐解决方案
You can do this by CSS (overwrite the default rule) or you can custom with a new class: 您可以通过CSS(覆盖默认规则)执行此操作,也可以使用新类进行自定义:
.dropdown-menu {
right:0;
left: auto;
}
In fact is the same thing this class .pull-right
from bootstrap library do: 事实上,这个类
.pull-right
来自bootstrap库是这样的:
CSS CSS
.pull-right {
right:0;
left: auto;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.