答案 0 :(得分:0)
引导程序在其样式表中设置white-space: nowrap
。
要自动换行,您需要将其更改为例如。 normal
在您的CSS中。
更多邻接空格属性:https://developer.mozilla.org/en-US/docs/Web/CSS/white-space
基于Bootstrap网站上的示例的简单代码段。
.dropdown-menu {
width: 150px;
}
.wordwrap {
white-space: normal !important;
}
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col">
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown button
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#">Text wihout any css</a>
<a class="dropdown-item wordwrap" href="#">Text with white-space set to normal</a>
</div>
</div>
</div>
</div>
</div>