When making forms, we often encounter the situation of aligning two fields, such as name, mobile phone number, and place of birth. In this way, we need to use text-align and text-justify styles. Just set text-align to justify. The situation of text-justify is complicated, and some people may not be familiar with it. The values of IE are as follows:
But it was originally implemented as a private feature of IE, like text-overflow, overflow-x, etc., and was not implemented until very late in FF. In other words, there are strict compatibility issues. In addition, FF and Chrome require manual insertion of spaces or soft line breaks between Chinese characters for this to take effect, and the resistance encountered in Chrome is even greater. p> plan: .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; } } Run the code: <!DOCTYPE HTML> <html> <head> <title>Text Alignment</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style> .box1{ background:red; width:30%; } .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; } } </style> </head> <body> <div class="box1"> <div class="test1">Name</div> <div class="test1">Name Name</div> <div class="test1">Name</div> <div class="test1">Location</div> <div class="test1">Workplace</div> </div> </body> </html> Summarize The above is the implementation code of CSS text alignment introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
>>: How to install OpenSuse on virtualbox
When we introduced nginx, we also used nginx to s...
MySQL 8.0.13 has a data folder by default. This f...
When doing DB benchmark testing, qps and tps are ...
Table of contents 1. What does shallow copy mean?...
motivation Due to learning needs, I purchased a v...
Installation environment: CentOS7 64-bit MINI ver...
Pure js implements a single-click editable table ...
Chapter 1 Source Code Installation The installati...
Download the Windows version of Nginx from the Ng...
In many cases, in order to beautify the form, the ...
1. Overflow content overflow settings (set whether...
In the process of web project development, we oft...
Those who have played King of Glory should be fam...
The detailed installation process of mysql5.7.21 ...
What are the attributes of the JS script tag: cha...