Show first 3 lines in HTML paragraph

前端 未结 3 1077
南方客
南方客 2021-01-04 23:07

I want to show only the first 3 lines of the paragraph below using HTML formatting. I am searching on W3Schools but it doesn\'t show how to do it.



        
3条回答
  •  心在旅途
    2021-01-04 23:54

    You can give the container a height and line-height and set its overflow property to hidden:

    HTML

    loremloremlorem...

    CSS

    p {
        height:60px;
        line-height:20px; /* Height / no. of lines to display */
        overflow:hidden;
    }
    

    JSFiddle example.

提交回复
热议问题