How to Use CSS to hide content beyond the display width

Source: Internet
Author: User

Tutorial on how to use CSS to hide content beyond the display width. It should be noted that this stuff is only effective for a single line of text. If you want to use it on multiple lines, it only works for the first line. This method is only written in IE, where "..." is hidden when the text of other browsers exceeds the specified width.

Reference content is as follows:
. Text-overflow {
Display: block;/* Add inline objects */
Width: 31em;/* specify the width */
Word-break: keep-all;/* Do not wrap */
White-space: nowrap;/* force all texts to be displayed in the same row until the text ends or br objects are encountered. Do not wrap */
Overflow: hidden;/* Hide the content beyond the width of the content */
Text-overflow: ellipsis;/* Private Attribute of IE. When the text in the object overflows, the omitted mark (...) is displayed. It must be used with overflow: hidden. */
}

Definition of table text overflow:

Reference content is as follows:
Table {
Width: 30em;
Table-layout: fixed;/* the following definition of td takes effect only when the table layout algorithm is defined as fixed. */
}
Td {
Width: 100%;
Word-break: keep-all;/* Do not wrap */
White-space: nowrap;/* Do not wrap */
Overflow: hidden;/* Hide the content beyond the width of the content */
Text-overflow: ellipsis;/* indicates the omitted mark (...) when the text in the object overflows. It must be used with overflow: hidden. */
}

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.