Multi-Line overflow ellipsis

Source: Internet
Author: User

Multi-line ellipsis appears in recent projects ~

All I knew before was text-overflow:ellipsis~, but it turned out to be useful for one line of text.

And then look at all kinds of check and summarize

1. If you only use care WebKit the kernel browser ~ then ~ directly

Overflow:hidden;
Text-overflow:ellipsis;
Display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:5; (The number of rows you want to limit)

This is the most ~ simple ~ and can meet the adaptive, that is, beyond the height of the ellipsis, not exceeding the normal display.

2. But there's a bunch of unsupported browsers

p {

Line-height:1em;

Height:5em; (Note This method line-height and height settings are best with EM)

Overflow:hidden;

Position:absolute;

}

P:after {

position:relative;

right:0;

bottom:0;

Content: ' ... '

。。。 Here also need to complement the background white, make fast, block display, etc.

}

This method is to use the ellipsis to cover the final text, if not support after the use of a tag instead of

But! This method is too rigid ~ If the content does not exceed the limit height, there is an ellipsis?? = = Too weird, if you can guarantee that your content is

is a board, then use this bar, simple and fast.

If not satisfied ... So certainly will think to use JS to judge = = Ah good trouble

3. Then recommend you directly with the JS plugin jquery dotdotdot.js;

Direct after introduction

$ (' P '). Dotdotdot (); P's style is set up ~

Multi-Line overflow ellipsis

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.