When you make a form today, you get the top two fields aligned, the phone number, the user name.
Then today on the Internet to find the relevant methods, found that there is really no good way to solve, especially when the need for compatibility. Found two ways that I think are relatively good:
Method One, is in Masaki's blog to see the--text-align, text-justify;
Need to set text-align to justify on the line, text-justify situation is more complicated. The values of IE are as follows:
- Auto: Allows the browser user agent to determine the justification used
- Inter-word: Aligns the text by increasing the space between the words. This behavior is the quickest way to align all lines of text. Its justification behavior is not valid for the last line of a paragraph
- Newspaper: aligns text by increasing or decreasing the spacing between words or letters. is the most precise format for the Latin alphabet justification
- Distribute: Handling whitespace is much like newspaper, which works for East Asian documents. Especially Thailand.
- Distribute-all-lines: Both ends of the hyphenation are the same way as distribute and do not contain the last line of two paragraphs aligned. Applies to ideographic documents
- Inter-ideograph: Provides full justification for ideographic text. He increases or decreases the space between ideographic words and words
But it was originally implemented as a private implementation of IE, such as text-overflow, overflow-x, etc., at FF very late, in other words there are strict compatibility issues. and ff,chrome need to manually insert blank or soft line labels between Chinese characters to take effect, and the resistance in chrome is even greater.
. 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; } }
This method tried, found that there are some problems, is test1 need block element, if it is navigation label, need to set display:block;
Original article: http://www.cnblogs.com/rubylouvre/archive/2012/11/28/2792504.html
Method Two, this is inadvertently seen, before also thought but never did so, did not think really someone did.
is to use the table method, according to the form of the way to do, so the text will certainly be divided evenly. (O (∩_∩) o haha ~ don't despise me! )
You can also set the Display:table property similarly:
The table layer sets the DISPLAY:TABLE,TD layer settings Display:table-cell.
Of course the principle is the same, so do need each word a frame separated, the method is really good, but feel very BT.
CSS Implementation Justification ~