CSS implements DIV ultra-long truncation and displays..., cssdiv truncation ..

Source: Internet
Author: User

CSS implements DIV ultra-long truncation and displays..., cssdiv truncation ..

The content displayed in the DIV is sometimes too long and the page is ugly,

The previous practice was to determine the length in JS or in the background. If it is too long, it will be truncated,

However, because the width of Chinese and English numbers is not the same, the truncation length can only be the minimum value,

The display effect is not good either. The method provided by CSS can perfectly solve this problem.

1. project-Name {2 width: 280px; 3 overflow: hidden; 4 text-overflow: ellipsis; 5 white-space: nowrap; 6}

The width must be defined here,

Overflow: hidden; indicates that the extra-long part is not displayed.
Text-overflow: ellipsis; indicates ultra-long display...
White-space: nowrap; indicates no rows are displayed.

This style can also be applied to some other labels. It is best to use it on tags that can be added with TITLE,
Because you can add a TITLE to display all the information.

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.