我想text-overflow在表格单元格中使用CSS ,这样如果文本太长而无法放在一行上,它将使用省略号剪辑而不是换行到多行.这可能吗?
我试过这个:
td {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Run Code Online (Sandbox Code Playgroud)
但white-space: nowrap似乎使文本(及其单元格)不断向右扩展,推动表格的总宽度超出其容器的宽度.但是,如果没有它,当文本到达单元格边缘时,文本将继续换行到多行.
我的CSS:
#content_right_head span
{
display:inline-block;
width:180px;
overflow:hidden !important;
}
Run Code Online (Sandbox Code Playgroud)
现在它正在显示内容内容
但我希望展示 内容内容......
我需要在内容后显示点.内容来自数据库动态.
有没有解决方案在div中的最后一行添加省略号,流体高度(20%)?
我-webkit-line-clamp在CSS中找到了这个函数,但在我的例子中,行号将取决于窗口大小.
p {
width:100%;
height:20%;
background:red;
position:absolute;
}Run Code Online (Sandbox Code Playgroud)
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sed dui felis. Vivamus vitae pharetra nisl, eget fringilla elit. Ut nec est sapien. Aliquam dignissim velit sed nunc imperdiet cursus. Proin arcu diam, tempus ac vehicula a, dictum quis nibh. Maecenas vitae quam ac mi venenatis vulputate. Suspendisse fermentum suscipit eros, ac ultricies leo sagittis quis. Nunc sollicitudin lorem eget eros eleifend facilisis. Quisque bibendum sem at bibendum suscipit. …Run Code Online (Sandbox Code Playgroud)可能重复:
是否可以使用javascript或css实现overflow:省略号的效果?
如何使用CSS将长文本指定到较小的固定列中?
我希望修剪文本,如果它大于300px宽,带"......"
例如,如果我有:
<ul>
<li>this is greater than 300px, than only display as much of the text that is 300px wide and then replace the remaining text with "..."</li>
<li>short, don't trim</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
将显示为:
this is greater than 300px, than only ...
short, don't trim
|----------- 300px wide ----------------|
Run Code Online (Sandbox Code Playgroud)
我如何用CSS/HTML做到这一点?
是否可以隐藏溢出文本的中间而不是结尾?例如用句点替换溢出的文本.
我现在在桌子上专门谈论,但任何可能的方式都会很有用.
所以我的意思是缩短112233445566778899为112...899(或类似的东西)而不是11223344
我不太了解JavaScript,但如果这是唯一的方式让我知道如何,我将通过教程找出其余部分.
我希望HTML中的标签最大宽度为100px,如果此标签的文本长度超过100px则会被切断.一个完美的结果将是一个削减,最后一些点"..".
我有:
<label> This is some long text on my website </label>
Run Code Online (Sandbox Code Playgroud)
期望的结果将是这样的:
这是一些...
单独使用CSS是否可行?首先,如果它只在最后被削减,那就没关系.先感谢您!
我试图在CSS中将宽度设置为100px,但这只会改变标签的背景颜色而不是文本的大小.