Home  >  Article  >  Web Front-end  >  How text-align achieves alignment at both ends

How text-align achieves alignment at both ends

php中世界最好的语言
php中世界最好的语言Original
2018-03-20 09:36:534562browse

This time I will bring you text-alignHow to achieve alignment at both ends, and text-align to achieve alignment at both ends. take a look. Method 1: text-align-last: justify;

html

<p>
        <p class="item">
            <label for="name" class="itemLabel">姓名</label>
            <input type="text" class="itemContent" id="name">
            
        </p>
        <p class="item">
            <label for="phone" class="itemLabel">手机号</label>
            <input type="text" class="itemContent" id="phone">
        </p>
        
 </p>

css

 .itemLabel{
            display: inline-block;
            width: 60px;
            text-align-last:justify;
    }

Due to the compatibility issue of text-align-last:

https://

caniuse.com/#search=text-align-last, you need to use method 2 to implement: css

        .item{
            position: relative;
        }
        .itemContent{
            position: absolute;
            left:70px;
        }
        .itemLabel{
            display: inline-block;
            width: 60px;
            text-align: justify;
        }
       .itemLabel:after{
            display: inline-block ;
            content: ''; 
            width: 100%;
        }

I believe you have read the case in this article After mastering the method, please pay attention to other related articles on the php Chinese website for more exciting content!

Recommended reading:

How to deploy HTTPS in Node.js


Using JavaScript scope

The above is the detailed content of How text-align achieves alignment at both ends. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn