首頁  >  文章  >  web前端  >  text-align如何實現兩端對齊

text-align如何實現兩端對齊

php中世界最好的语言
php中世界最好的语言原創
2018-03-20 09:36:534507瀏覽

這次帶給大家text-align如何實現兩端對齊,text-align實現兩端對齊的注意事項有哪些,下面就是實戰案例,一起來看一下。

法一: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;
    }

由於text-align-last的兼容性問題: https://caniuse.com/#search=text-align-last,需要使用法二實作:

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%;
        }

相信看了本文案例你已經掌握了方法,更多精彩請關注php中文網其它相關文章!

推薦閱讀:

Node.js怎麼部署HTTPS

#JavaScript作用域的使用

以上是text-align如何實現兩端對齊的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn