gpt4 book ai didi

html - 第二行的css省略号

转载 作者:行者123 更新时间:2023-11-28 04:10:46 25 4
gpt4 key购买 nike

CSS text-overflow: ellipsis 在第二行,这可能吗?我在网上找不到它。

例子:

我想要的是这样的:

I hope someone could help me. I need 
an ellipsis on the second line of...

但实际情况是这样的:

I hope someone could help me. I ... 

最佳答案

这应该在 webkit 浏览器中工作:

overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;

browser support

div {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}

* { font-family: verdana; }
<div>
The <b><a target='_blank' href='https://developer.mozilla.org/docs/Web/CSS/-webkit-line-clamp'>-webkit-line-clamp</a></b> CSS property allows limiting of the contents of a block container to the specified number of lines. It only works in combination with the display property set to <b>-webkit-box</b> or <b>-webkit-inline-box</b> and the <b>-webkit-box-orient</b> property set to vertical. In most cases you will also want to set overflow to hidden, otherwise the contents won't be clipped but an ellipsis will still be shown after the specified number of lines. When applied to anchor elements, the truncating can happen in the middle of the text, not necessarily at the end.
</div>

关于html - 第二行的css省略号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42728955/

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