您好,登錄后才能下訂單哦!
這篇文章主要介紹怎么使用CSS實(shí)現(xiàn)文本左對(duì)齊、右對(duì)齊和居中對(duì)齊,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
語(yǔ)法格式:
text-align:(文本位置)
位置 說(shuō)明
left 左對(duì)齊
right 右對(duì)齊
center 居中對(duì)齊
justify 兩端對(duì)齊
接下我們來(lái)分別看看這四種對(duì)齊方式的設(shè)置方法
文本左對(duì)齊的設(shè)置方法:
text-align:left;
文本右對(duì)齊設(shè)置方法:
text-align:right;
文本居中對(duì)齊設(shè)置方法:
text-align:center;
文本兩端對(duì)齊設(shè)置方法:
text-align:justify;
我們來(lái)看具體的代碼示例1:
TextAlign.html
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8"/>
<linkrel="stylesheet"href="TextAlign.css"/>
<title></title>
</head>
<body>
<divclass="TextLeft">
php中文網(wǎng)左對(duì)齊<br/>
php中文網(wǎng)<br/>
php中文網(wǎng)<br/>
php
</div>
<divclass="TextRight">
php中文網(wǎng)右對(duì)齊<br/>
php中文網(wǎng)<br/>
php中文網(wǎng)<br/>
php
</div>
<divclass="TextCenter">
php中文網(wǎng)居中對(duì)齊<br/>
php中文網(wǎng)<br/>
php中文網(wǎng)<br/>
php
</div>
<divclass="TextJustify">
php中文網(wǎng)<br/>
兩端對(duì)齊<br/>
php中文網(wǎng)<br/>
php
</div>
</body>
</html>
TextAlign.css
.TextLeft{
margin-top:24px;
margin-left:32px;
border:1pxsolid#ff6a00;
width:480px;
text-align:left;
}
.TextRight{
margin-top:24px;
margin-left:32px;
border:1pxsolid#ff6a00;
width:480px;
text-align:right;
}
.TextCenter{
margin-top:24px;
margin-left:32px;
border:1pxsolid#ff6a00;
width:480px;
text-align:center;
}
.TextJustify{
margin-top:24px;
margin-left:32px;
border:1pxsolid#ff6a00;
width:480px;
text-align:justify;
text-justify:distribute-all-lines;
}
以上是“怎么使用CSS實(shí)現(xiàn)文本左對(duì)齊、右對(duì)齊和居中對(duì)齊”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。