+ -
当前位置:首页 → 问答吧 → 关于span居中的问题

关于span居中的问题

时间:2011-08-30

来源:互联网

比如有个span内有换行:
<span>
<p>第一行</p>
<p>这是第二行</p>
</span>
我想让他居中但不是每行都居中
如果用span{text-align:center;}的话:
 第一行
这是第二行 
会这样,但是我要的效果是不变但是整体居中:
第一行
这是第二行
请问如何操作?谢谢!

作者: Linktwelve   发布时间: 2011-08-30

HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<style>
    *{margin:0; padding:0;}
    div{width:800px; border:1px solid #000; height:20px; margin:0 auto;}
    span{ margin:0 auto; width:80px; display:block;}
</style>
<body>

    <div>
    <span>
<p>第一行</p>
<p>这是第二行</p>
</span>
</div>


</body>
</html>

作者: MuBeiBei   发布时间: 2011-08-30

热门下载

更多