Reprint --- CSS text alignment at both ends

Source: Internet
Author: User

Align the two ends: Set the two ends of the text content, adjust the horizontal spacing of the text, so that it is evenly distributed between the left and right margins. Alignment on both ends makes the text on both sides neatly edges. Each row of the selected content is aligned to both sides of the page. The distance between words is automatically allocated based on the number of characters in each row.

------------------------------------------------ Reprint original ---------------------------------------------------

During form creation, we often encounter alignment of the upper and lower fields, such as name, mobile phone number, and place of birth. In this case, we need to use the text-align and text-justify styles.

Text-align can be set to justify directly. The text-justify situation is complicated. Some people may be unfamiliar with it. The values of IE are as follows:

  • Auto: allows the browser user agent to determine the two-end alignment rules used
  • Inter-word: Align text by adding spaces between words. This behavior is the fastest way to align all text rows. The alignment at both ends of the paragraph is invalid for the last line of the paragraph.
  • Newspaper: Align text by adding or removing spaces between words or letters. Is the most precise format used for alignment at both ends of the Latin alphabet
  • Distribute: Processing spaces is similar to newspaper. It is applicable to East Asian documents. Especially Thailand
  • Distribute-all-lines: the two ends are in the same way as distribute, and they do not contain the last line of the two section alignment. Applies to ideographic documents
  • Inter-ideograph: provides full two-end alignment for ideographic text. He adds or removes spaces between ideographic words and words.

However, it was first implemented as a private Implementation of IE, such as text-overflow and overflow-x. It was implemented very late in FF, in other words, there was a strict compatibility problem. And FF, chrome needs to manually insert blank or soft line feed labels between Chinese characters to take effect, the resistance encountered in chrome is even greater.

I have been chatting with friends in the QQ Group over the past two days. Finally, I will give an ultimate solution:

.test1 {      text-align:justify;      text-justify:distribute-all-lines;/*ie6-8*/      text-align-last:justify;/* ie9*/      -moz-text-align-last:justify;/*ff*/      -webkit-text-align-last:justify;/*chrome 20+*/  }  @media screen and (-webkit-min-device-pixel-ratio:0){/* chrome*/      .test1:after{          content:".";          display: inline-block;          width:100%;          overflow:hidden;          height:0;      }  }
<! Doctype html> 

 

Original article address:Css text alignment

 
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.