我正在使用Boostrap 4的网页上有类似以下内容的部分
.parent {
overflow-x :auto;
width: 200px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="parent">
<div class="dropdown">
<button class="dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Group Communications & Social Responsiblity Unit<i class="icon-chevron-down"></i></button>
<div class="dropdown-menu">
<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>
</div>
类别为parent
的元素具有overflow-x:auto;
与此相关的下拉菜单不显示菜单项
答案 0 :(得分:0)
在下拉列表中使用position-absolute
类,并将显示属性设置为“静态”(data-display="static"
)...
<div class="parent">
<div class="dropdown position-absolute">
<button class="dropdown-toggle" type="button" data-toggle="dropdown" data-display="static" aria-haspopup="true" aria-expanded="false">Group Communications & Social Responsiblity Unit<i class="icon-chevron-down"></i></button>
<div class="dropdown-menu">
<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>
</div>