Show first 3 lines in HTML paragraph

前端 未结 3 1112
南方客
南方客 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:56

    You can use -webkit-line-clamp property with div.

    div {
      width: 100%;
      line-height: 1.2em;
      height: 3.6em;
      background-color: gainsboro;
      overflow: hidden;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
    }
    loremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremlore loremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremlore loremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremlore loremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremlore loremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremloremlore

提交回复
热议问题