CSS disables automatic text wrapping

Source: Internet
Author: User
When the Chinese text is too long (there are no spaces or line breaks in the middle), both IE and Firefox will automatically wrap at the boundary. However, in some cases, we do not want this. For example, you can use the "white-space: nowrap" attribute when you do not want to wrap the last Li text in each line in several Li lines.

After this CSS attribute is used, text can be wrapped only when spaces or line breaks are encountered. For example:
<Style type = "text/CSS">
Div {width: 300px; Border: 1px solid red; margin: 10px; overflow: hidden ;}
. Nowrap {white-space: nowrap ;}
</Style>
<Div class = "nowrap"> This is a long piece of text with no spaces or line breaks in it. It does not automatically wrap the text until it is truncated. </div>
<Div> This is a long text with no spaces or line breaks in the middle, but it will automatically wrap </div>

The text in the above two divs contains the ultra-wide text. The line feed in the first one is forbidden, and the ultra-wide text is intercepted. The second one is not set, so the text is automatically wrapped.

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.