CSS adds ellipsis attributes beyond one line: Text-overflow and White-space

Source: Internet
Author: User

CSS Properties White-space

<p style= "width:300px; Overflow:hidden; White-space:nowrap; text-overflow:ellipsis; " > Omit me, omit me, omit me, omit me, omit me, omit me, omit me, omit me, omit me </p>

Test Explorer: IE6/7/8/9, opera12.02, firefox15.0.1, chrome21.0.1180.89 m

1, text-overflow:ellipsis;

The main style here is text-overflow:ellipsis;

However, Text-ellipsis is a special style, the explanation is this: the Text-overflow property is only annotations, and if the text overflows, the ellipsis is displayed. No other style attribute definitions are available. The effect of an ellipsis on overflow must also be defined: Force the text to appear on one line (white-space:nowrap) and overflow content as hidden (Overflow:hidden), only in order to achieve the effect of overflow text display ellipsis.

This needs to limit the width, the text is displayed on one line (white-space:nowrap;), and the hidden attribute overflow is used.

Online to support the lower version of opera one way is to-o-text-overflow:ellipsis;

2.white-space Property

Normal default. The blank will be ignored by the browser.

The pre blank is reserved by the browser. It behaves like a <pre> tag in HTML.

The nowrap text does not wrap, and the text continues on the same line until the <br> tag is encountered.

Pre-wrap preserves a sequence of whitespace characters, but wraps normally.

Pre-line merges a sequence of whitespace characters, but preserves newline characters.

Inherit specifies that the value of the White-space property should be inherited from the parent element.
Object.style.whitespace=normal|nowrap|pre

3.word-wrap

1. (IE) consecutive English characters and Arabic numerals, using Word-wrap:break-word; or word-break:break-all; implement force break

2. (Firefox browser) consecutive lines of English characters and Arabic numerals, all versions of Firefox do not solve this problem, we only let the characters beyond the boundary hide or add a scrollbar to the container
. a{word-break:break-all; width:200px; overflow:auto;}

. (Firefox browser) use table-layout:fixed, force table width, inner layer td,th adopt word-break:break-all; or Word-wrap:break-word; newline, use overflow : Hidden; Hide beyond content, here Overflow:auto; not working

CSS adds ellipsis attributes beyond one line: Text-overflow and White-space

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.