css - Bootstrap 4 列表项仅单行(省略号不起作用)
问题描述
我有一张带有列表项的 Bootstrap 4 卡。我希望每个列表文本只有单行,并且占据卡片的整个宽度,否则显示 3 个点(省略号)或简单地用 隐藏它overflow:hidden
,但它不起作用。
这就是问题:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card">
<ul class="list-group list-group-flush">
<li class="list-group-item"><p>Long content ............. Here. Overflow Ellipsis or Hidden not working (This should be 1 line of card width, on all screen sizes, and depending on screen size)</p></li>
<li class="list-group-item"><p>Second List Item</p></li>
<li class="list-group-item"><p>Third List Item</p></li>
</ul>
</div>
解决方案
只需使用 Bootstrap 4text-truncate
类..
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="card">
<ul class="list-group list-group-flush">
<li class="list-group-item"><p class="text-truncate">Long content ............. Here. Overflow Ellipsis or Hidden not working (This should be 1 line of card width, on all screen sizes, and depending on screen size)</p></li>
<li class="list-group-item"><p>Second List Item</p></li>
<li class="list-group-item"><p>Third List Item</p></li>
</ul>
</div>
推荐阅读
- node.js - 带有 React 前端的 NodeJS/Express API 实时通知
- java - 有条件地记录信息的最有效方法是什么?
- assembly - 在 x86_x64 架构上组装 x86 汇编源代码
- excel - 有一个更好的方法吗?VBA 脚本
- c# - Visual Studio 如何在 Regex 构造函数中语法高亮字符串?
- javascript - 如何使我的 chrome 扩展程序正常工作?
- javascript - 如何通过在另一个数组中搜索来过滤列表中的数组?
- c# - 从 c# 调用 oracle 函数时输入字符串的格式不正确
- c# - UWP 应用程序在尝试从 WebView ScriptNotify 打开文件选择器时崩溃,即使由 Dispatcher 运行也是如此
- asp.net - Azure DevOps Pipelines 可以构建 ASP.NET 网站吗?