语法格式:
text-align:(文本位置)
位置 说明
left 左对齐
right 右对齐
center 居中对齐
justify 两端对齐
接下我们来分别看看这四种对齐方式的设置方法
文本左对齐的设置方法:
text-align:left;
文本右对齐设置方法:
text-align:right;
文本居中对齐设置方法:
text-align:center;
文本两端对齐设置方法:
text-align:justify;
我们来看具体的代码示例1:
TextAlign.html
<!DOCTYPEhtml>
<html>
<head>
<metacharset="utf-8"/>
<linkrel="stylesheet"href="TextAlign.css"/>
<title></title>
</head>
<body>
<divclass="TextLeft">
php中文网左对齐<br/>
php中文网<br/>
php中文网<br/>
php
</div>
<divclass="TextRight">
php中文网右对齐<br/>
php中文网<br/>
php中文网<br/>
php
</div>
<divclass="TextCenter">
php中文网居中对齐<br/>
php中文网<br/>
php中文网<br/>
php
</div>
<divclass="TextJustify">
php中文网<br/>
两端对齐<br/>
php中文网<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;
}


本文转载自中文网


本文转载自中文网
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css3-style/c56617.shtml