Pure CSS Ellipsis For Three or More Lines of Text

后端 未结 1 676
臣服心动
臣服心动 2021-01-13 07:41

Is there a CSS-only way (no JavaScript/jQuery) to only show the first two lines and, if there are three or more lines, hide the extra lines and show an ellipsis?

For

相关标签:
1条回答
  • 2021-01-13 08:07

    You can use text-overflow:ellipsis property with height.

    Like this

    .truncate 
    {
    width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    height:100px;
    }
    

    By using text-overflow, you can display your output without using javascript.

    Sources

    Source Link

    To Learn more about truncating. Read this link

    New Update

    For multiline ellipsis you can use this method.

    css
    .classname:after{
    content: "\02026";
    } 
    

    Multiline-Ellipsis

    Few Links which i think might be useful

    1.Codepen example

    2.Css Tricks

    0 讨论(0)
提交回复
热议问题