gpt4 book ai didi

twitter-bootstrap - 如何在 Bootstrap 列中使用文本溢出?

转载 作者:行者123 更新时间:2023-11-28 09:17:32 25 4
gpt4 key购买 nike

假设我有一行高度固定,我在它的列中插入了一些文本。如果太长,我想将其截断,并在行尾添加三个点,如下所示:

enter image description here

我在我的行中为此使用了 text-overflow: ellipsis; 属性,但无法使其正常工作。

enter image description here

JsFiddle

我做错了什么?

HTML

<div class="container">
<div class="row text">
<div class="col-xs-4" style="border: solid">
Some really long text! Some really long text! Some really long text! Some really long text! The end! Some really long text! The end! Some really long text! The end! Some really long text! The end!
</div>
</div>
</div>

CSS

.row {
margin: 2px 0;
}

.text {
word-wrap: break-word;
height: 50px;
text-overflow: ellipsis;
}

最佳答案

如果你想用 css 做这个,那么试试下面的代码:

HTML:

<div class="container">
<div class="row">
<div class="col-xs-4" style="border: solid">
<div class="text">
Some really long text! Some really long text! Some really long text! Some really long text! The end! Some really long text! The end! Some really long text! The end! Some really long text! The end!
</div>
</div>
</div>
</div>

CSS:

.row {
margin: 2px 0;
}

.text {
display: block;
display: -webkit-box;
max-width: 400px;
height: 50px;
margin: 0 auto;
line-height: 1.2;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}

这里是 jsfiddle

了解 css 中的线条拍手 Line Clamping

关于twitter-bootstrap - 如何在 Bootstrap 列中使用文本溢出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33165066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com