我正在尝试将我的文本包装在我的幻灯片菜单中。我有 ul max-width 200px,但是当我写更长的文本时,我的文本不可见(现在我添加了 overflow: visible 来向你展示我的意思)。如何包装这个?
我的代码如下所示:
<nav class="navbar navbar-default" role="navigation">
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Dropdown
<span class="caret"></span>
</button>
<ul class="dropdown-menu" style="max-width: 200px" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation" class="dropdown-header">Dropdown header</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
<li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation" class="dropdown-header">Dropdown header</li>
<li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
</ul>
</div>
</nav>
现在是 CSS:
<style>
.dropdown .dropdown-menu {
-webkit-transition: all 0.3s;
-moz-transition: all 0.3s;
-ms-transition: all 0.3s;
-o-transition: all 0.3s;
transition: all 0.3s;
max-height: 0;
display: block;
overflow: hidden; <-- here i was trying to add word-wrap: break-word; but it doesn'twork
opacity: 0;
}
.dropdown.open .dropdown-menu {
max-height: 200px;
opacity: 1;
}
</style>
原文由 wenus 发布,翻译遵循 CC BY-SA 4.0 许可协议
您可以在 ---
word-wrap: break-word;
li
。检查下面的更新片段..