【发布时间】:2017-11-11 01:13:46
【问题描述】:
我有一个宽度可变的 div(响应式)。文本内容由用户动态创建,因此行长可能因内容而异。有没有办法让里面的文本恰好重叠 3 行?理想情况下不使用 javascript 或 php(尽管如果 bootstrap 与 js 解决方案捆绑在一起,我并不强烈反对)
所以
<div>Here is some example text that regardless of the div width is always three lines</div>
将呈现为
Here is some example text that
regardless of the div width
is always three lines
无论 div 是跨越页面的整个宽度还是仅仅几个 rems。
And
another
example
我不想截断文本或添加省略号。如果文本从 div 溢出,但仍然堆叠成三行,这是可以接受的。如果它有所作为,我正在使用 bootstrap 4 beta。
【问题讨论】:
-
只需将 div 的高度设置为行高的 3 倍并添加溢出隐藏 - jsfiddle.net/uo30mwev
-
不幸的是,我认为你不能用 CSS 做到这一点......
标签: html css bootstrap-4