HTML/CSS -长单词替换为

HTML/CSS - long words replaced with

本文关键字:单词 替换 CSS HTML      更新时间:2023-09-26

我真的不知道怎么命名,所以我找不到一个好的搜索

我试图打破一个单词,但不是把这个单词放在下一行,我将在容器末尾的字母替换为…在Facebook的帖子中更像这样,出现了"查看更多"选项。

我该怎么做?

你可以使用css属性ellipsis截断'…'的长度

.your_class {
    text-overflow: ellipsis;
}

可以从本教程中学到更多的东西——省略号技巧

你可以试试下面的代码:

<div id="div2">This is some long text that will not fit in the box</div>
#div2
 {
   white-space:nowrap; 
   width:12em; 
   overflow:hidden;
   text-overflow:ellipsis; 
   border:1px solid #000000;
 }