CSS text out-of-section display ellipsis (original)

Source: Internet
Author: User

Single line out of ellipsis

#word1 {width:100px; text-overflow:ellipsis; overflow:hidden;}

A few lines beyond the ellipsis (compatible with the WebKit kernel only)

3; Overflow:hidden;}

Compatible wording (but when the text is not long enough when the ellipsis will still exist, you need to determine the JS)

#wordNV2 {width:100px; position:relative; overflow:hidden; word-break break-all; height:60px; line-  ' ... ' 0 0 (%);}

The first thing you need to add is the knowledge about line breaks (add the following line-wrapping CSS as the case requires)

First, forced line break
1 Word-break:break-all; Only works in English, with letters as the basis for line-wrapping.

2 Word-wrap:break-word; Only works in English, with words as the basis for line change.

3 white-space:pre-wrap; Only works on Chinese, forcing line wrapping.

The following conditions

This is the CSS part line ellipsis

#word1 {width:100px; height:20px; line-height:20px; text-overflow:ellipsis; overflow:hidden;}

Here is the display:

Why is this, because there is a space after a, the line is automatically wrapped, so the ellipsis is not displayed.

Here are the multi-line scenarios

So we need to set a new line of things.

Reprint Please specify source :http://www.cnblogs.com/matthew9298-Begin20160224/

CSS text out-of-section display ellipsis (original)

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.