是否可以使用CSS将文本长度限制为“n”行(或在垂直溢出时剪切)。
文本溢出:省略号;仅适用于1行文本。
原文:
Ultrices natoque mus mattis、aliquam、cras in pellentesquetincidunt elit purus lectus、vel ut aliquet、elementum nunc乌尔纳修女院!坐下!图比斯岛莫斯·廷西杜特!Dapibus sed aenean、magna sagitis、lorem velit
所需输出(2行):
Ultrices natoque mus mattis、aliquam、cras in pellentesquetincidunt elit purus lectus,velut aliquet,elementum。。。
我一直在寻找这个,但后来我意识到,该死的我的网站使用php!!!为什么不在文本输入上使用修剪功能并播放最大长度。。。。
对于那些使用php的人,这里也有一个可能的解决方案:http://ideone.com/PsTaI
<?php
$s = "In the beginning there was a tree.";
$max_length = 10;
if (strlen($s) > $max_length)
{
$offset = ($max_length - 3) - strlen($s);
$s = substr($s, 0, strrpos($s, ' ', $offset)) . '...';
}
echo $s;
?>
我一直在寻找这个,但后来我意识到,该死的我的网站使用php!!!为什么不在文本输入上使用修剪功能并播放最大长度。。。。
对于那些使用php的人,这里也有一个可能的解决方案:http://ideone.com/PsTaI
<?php
$s = "In the beginning there was a tree.";
$max_length = 10;
if (strlen($s) > $max_length)
{
$offset = ($max_length - 3) - strlen($s);
$s = substr($s, 0, strrpos($s, ' ', $offset)) . '...';
}
echo $s;
?>