The ellipsis is displayed when the content controlled by CSS exceeds the container width.

Source: Internet
Author: User
We usually see a news list, for example, in order to keep the text blank and control the number of words, we will use the program to display the ellipsis for extra characters. We can only use CSS to achieve the same effect, although not perfect.
Li {width: 50px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden ;}
First, it is a container, which can be div, Li, TD, etc. First, define the width. "white-space: nowrap" is to force all text to be displayed in a row without returning rows. "Text-overflow: ellipsis" is the key.

Text-overflow is a new attribute of css3, which is supported by IE6 or later versions. It can contain two parameters: Clip [not displaying the omitted mark (...), but a simple crop]. ellipsis [displays the omitted mark (...) when the text in the object overflows]. Therefore, this method does not support Firefox. Therefore, we need to add overflow: hidden to hide unnecessary words in ff.
This method is very useful for our website. Because the input box supports the extension area and the two-zone input in the basic area, the extended area text copied from other websites can be normal and realistic, but there is always a problem in length calculation! This method can be used to solve the problem, but it is widely used...
New things are good, but there are problems with compatibility ~

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.