Use of text-overflow in CSS

Source: Internet
Author: User
In the BS application we write, sometimes we want to display the data in the database in a table, but the data length is inconsistent. For the sake of beauty, many websites use ellipsis to display content. I have seen many websites retrieve data of the same length first, and then add a ellipsis. In fact, text-overflow in CSS can solve this problem. Syntax: Text-overflow: Clip| EllipsisValid value:
Clip : Default Value. The omitted mark (...) is not displayed, but a simple cropping
Ellipsis : When the text in the object overflows, the omitted mark (...) is displayed (...)
Note: sets or retrieves whether to use an omitted mark (...) to indicate text overflow in the object.
This attribute only applies to the horizontal inline direction, and the general Western text overflows. Inline overflow occurs when the text in the row exceeds the available width but there is no chance of line feed.
To force overflow and apply EllipsisValue. The author must set the white-space attribute value of the object Nowrap.
If there is no chance of line feed (for example, the width of the object container is narrow, and there is a long text without reasonable line breaks), there is no application NowrapIt may also overflow.
To enable EllipsisValue is applied. This attribute must be set to an object with an invisible area. The best choice is to set the overflow attribute Hidden. Set the overflow attribute ScrollOr AutoThis attribute is also applied. However, a scroll bar appears.
By selecting the omitted mark, you can select hidden text. When this option is selected, the omitted flag is hidden and replaced by text.
This attribute provides an efficient way to create an omitted tag in DHTML.
This property CurrentstyleThe object is read-only. Other objects can be read and written.
Corresponding script features: Textoverflow.

<Div style = "width: 100%; Height: 90px; Background-color: #87 ceeb; padding: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; "you can select the attribute value of the text in the selection box below. Take a look at what will happen, and then you will understand what they mean. </Div>
You can try it by yourself.

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.