CSS text is hidden and displays ellipses beyond 2 lines

Source: Internet
Author: User

Tag: SPL amp element hid lamp requires splay style elasticity

First, you need to know the three properties of CSS.

Overflow:hidden; Out-of-text hiding

Text-overflow:ellipsis; Overflow with ellipsis display

White-space:nowrap; Overflow does not break line

These three are the basic properties of CSS and need to be remembered.

But the third attribute, can only display one row, cannot use here, then if displays many lines?

CSS3 solves this problem with the following workaround:

Display:-webkit-box; Displays the object as an elastic telescopic box model.

-webkit-box-orient:vertical; Arranges child elements vertically from top to bottom (sets the arrangement of child elements of the telescopic box)

-webkit-line-clamp:2; This property is not a canonical property of CSS and requires the combination of the above two properties to represent the number of rows displayed.

The final CSS style is as follows:

Overflow:hidden;

Text-overflow:ellipsis;

Display:-webkit-box;

-webkit-box-orient:vertical;

-webkit-line-clamp:2;

CSS text is hidden and displays ellipses beyond 2 lines

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.