Mobile multi-line text overflow ellipsis

Source: Internet
Author: User

I. Overflow display ellipsis (Universal) for single-line text

The Text-overflow property specifies what happens when the text overflows the containing element. Ellipsis displays the ellipsis to represent the trimmed text.

The White-space property sets how to handle white space characters within an element. NoWrap indicates that the text does not wrap, and the text continues on the same line until the <br> tag is encountered.

{            overflow: hidden;             text-overflow: ellipsis;             white-space: nowrap;        }

Two. Overflow of multiple lines of text display ellipsis (mobile side)

-webkit-line-clamp is a non-canonical attribute that does not appear in the draft CSS specification. -webkit-line-clamp limits the number of lines of text displayed in a block element.

This property is more suitable for browsers WebKit browsers or mobile (mostly WebKit cores).

To achieve this effect, it needs to combine other foreign webkit properties. Common binding Properties:

    • display: -webkit-boxYou must combine the properties to display the object as an elastic telescopic box model.
    • -webkit-box-orient:vertical必须结合的属性To set or retrieve the arrangement of child elements of a telescopic box object.
. more {            display: -webkit-box;             -webkit-box-orient: vertical;             Overflow: hidden;             text-overflow: ellipsis;             word-break: break-all;             -webkit-line-clamp:2;        }

Three. Demo

<! DOCTYPE html> One{Overflow:Hidden;Text-overflow:ellipsis;White-space:nowrap; }. more{Display:-webkit-box;-webkit-box-orient:Vertical;Overflow:Hidden;Text-overflow:ellipsis;Word-break:Break-all;-webkit-line-clamp:2; }</style>

Mobile multi-line text overflow ellipsis

Related Article

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.