+ -
当前位置:首页 → 问答吧 → 关于div+css中的margin auto问题

关于div+css中的margin auto问题

时间:2011-11-06

来源:互联网

HTML code
<html>
    <head>
        <title>内容页</title>
        <meta http-equiv="content-type" content="text/html;charset=gb2312" />
    <style>
        div{    
            width:500px;
            height:400px;
            background:gray;
        }
        p.test{
            width:100px;
            margin:auto;
            background:green;
        }
        </style>
    </head>
    <body>
        <div>
          <p class="test">
                测试内容测试内容测试内容
          </p>
        </div>
    </body>
</html>




书上的效果是“测试内容测试内容测试内容”在div块的中间,为什么我用了这个代码却是在div的左上角顶格?

作者: fantassly2010   发布时间: 2011-11-06

书上是垂直水平都居中吗?

作者: zszhaozwj   发布时间: 2011-11-07

热门下载

更多