CSS automatic line feed, force line break, force line break, excessive display ellipsis

Source: Internet
Author: User

CSS automatic line feed, force line break, force line break, excessive display ellipsis

P labels are automatically wrapped by default. Therefore, setting the width can achieve better results. However, recently, after loading data using ajax, the content in the p label does not have a line break, leading to layout disorder. So I tried to use the line feed style. Although the problem was solved, I did not find the essential cause. The essence is that, the data I obtained at the time was a long string of numbers. the browser should be able to process numbers in a similar way as English words without truncation.
First, various methods are provided, and then each attribute is described in detail.
Force do not wrap
P {white-space: nowrap ;}

Automatic line feed
P {word-wrap: break-word ;}

Force an English word to break a line
P {word-break: break-all ;}

* Note: to force an English word to break a line, you must set the line element to a block-level element.

The ellipsis is displayed.
P {text-overflow: ellipsis; overflow: hidden ;}

White-space: normal | pre | nowrap | pre-wrap | pre-line | inherit;
White-space attribute settings
Normal default. The blank space is ignored by the browser.
Pre blank is retained by the browser. The behavior is similar to the pre Tag in HTML.
The nowrap text will not wrap, and the text will continue on the same line until the br label is encountered.
Pre-wrap retains the blank character sequence, but line breaks are normally carried out.
Pre-line merges the blank character sequence, but retains the line break.
Inherit specifies that the value of the white-space attribute should be inherited from the parent element.

Word-wrap: normal | break-word;
The word-wrap attribute is used to indicate whether the browser is allowed to break a sentence in a word. This is to prevent overflow when a string is too long and cannot be found.
Normal)
Break-word: line feed within a long word or URL address
Word-break: normal | break-all | keep-all;

The word-break attribute is used to indicate how to break a sentence in a word.
Normal: use the default line feed rule of the browser.
Break-all: allow the next line break

Keep-all: line breaks can only be entered with halfwidth spaces or hyphens

 

 
       

Wordwrap: breakword; absavhsafhuafdfbjhfvsalguvfaihuivfs

Wordwrap: break-word; absavhsafhuafdfbjhfvsalguvfaihui

Wordwrap: break-word; absavhsafhuafdfbjhfvsalguvfaihuivf

Wordwrap: breakword; absavhsafhuafdfbjhfvsalguvfaihuivfsa

Wordwrap: breakword; absavhsafhuafdfbjhfvsalguvfaihuivfsab

 

The effect is as follows:


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.