Some questions about character wrapping in CSS

Source: Internet
Author: User

We are dealing with the content of the article in the process because the content of the article mixed with Chinese, English, numerals and other characters, and our common English and the number is unable to wrap elements in the automatic line, which will often lead to the elements are bursting, as shown in the following figure:

CSS in Word-break can solve this problem, write a test page to make a note

CSS code:

body{font-size:14px;}  p{border:solid 1px red;width:200px;}

HTML code:


English Chinese Chinowen englis333henglishenglishenglish Chinese English Chinese Chinese Chinoven Chinoven Chinoven        123ewewee 123EnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglishEnglis Henglishenglishenglish

At this point the operating effect such as the opening of the premises said that the following P tags add some style

CSS code:

. test{Word-break:break-all;}

The effect is as follows:

You can find that all the text, whether Chinese or English or digital, can automatically force a career change at the end of the p tag of the package, which will have a problem that would have been a combination of strings split to see the effect, and then look at a

CSS code:

. test {word-break:hyphenate;}

The effect is as follows:

This CSS will probably burst the wrapping element's character segment at the hyphenation point to wrap the line in advance

Look again

CSS code:

. test{Word-break:keep-all;}

The effect is as follows:

Wraps a line between all character and character segments, preserving the integrity of all character segments. Bursting package elements

Word-break also has some properties:

CSS code:

. test{Word-break:normal;} /* Browser Default line break * *

If you do not need to maintain the integrity of the word, break-all can solve the problem of bursting containers, because in the actual application process will not have a length of more than a container width of words, so hyphenate can solve the word is complete and can not burst the container, Second, in some scenarios can use the scroll bar or Overflow:hidden to maintain the integrity of the interface.



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.