您的位置:首页 > 其它

多行文字水平垂直居中在div

2015-07-16 15:43 337 查看
<BODY>
<div class="box">
<h3>1.单行文字居中</h3>
<!--设置行高来实现-->
<div class="box1">
这是高度为30像素的单行文字
</div>

<h3>2.多行文字不定高度居中</h3>
<!--运用padding来实现-->
<div class="box2">
<div>多行文字不定高度居中</div>
<div>多行文字不定高度居中</div>
<div>多行文字不定高度居中</div>
</div>

</div>
</BODY>
=============================

.box {
width: 800px;
margin: 50px auto;
border: 1px solid red;
font-size: 16px;
text-align: center;
}
.box1 {
border: 1px dashed red;
line-height: 40px;
margin: 30px;
}
.box2 {
border: 1px dashed red;
padding: 60px 0;
margin: 30px;
}

参考: http://www.cnblogs.com/siqi/archive/2013/06/16/3138289.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: