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
The Nginx ngx_http_image_filter_module module (ng...
I have been researching Linux recently and tried ...
They are all web page templates from the foreign ...
Table of contents 1. Create a new project 2. Add ...
Although Mac systems come with PHP and Apache, so...
This article describes the MySQL transaction mana...
The specific code is as follows: <a href="...
1. HTML Image <img> 1. The <img> tag ...
There are the following log files in MySQL: 1: re...
1 Introduction Good coding habits are qualities t...
What is a tree in web design? Simply put, clicking...
I was recently working on a project about face co...
In our life, work and study, social networks have ...
General mobile phone style: @media all and (orien...
Apache Arrow is a popular format used by various ...