问答详情
源自:12-12 宰相肚里能撑船 - 使用padding为盒子设置内边距(填充)

如何使得盒子1位于边界的中心啊

TYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>填充</title>

<style type="text/css">

#box1{

    width:100px;

    height:100px;

    padding:10px;

    border:1px solid red;

}

</style>

</head>

<body>

<div id="box1">盒子1</div>

</body>

</html>


提问者:多多尘 2016-03-08 13:57

个回答

  • qq_曾经我也帅过_0
    2016-03-08 14:08:16
    已采纳

    div{text-align:center;}

  • Zz张浩
    2016-03-08 17:04:45

    <!DOCTYPE HTML>

    <html>

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">

    <title>填充</title>

    <style type="text/css">

    #box1{

        width:100px;

        height:100px;

        padding:10px;

        border:1px solid red;

        text-align:center;

    }

    span{

        display:block;

        margin-top:40px;

    }

    </style>

    </head>

    <body>

    <div id="box1"><span>盒子1</span></div>

    </body>

    </html>


  • Beyondtow
    2016-03-08 14:08:37

    text-align:center;

  • 慕田峪3393512
    2016-03-08 14:06:57

    center

  • qq_安_24
    2016-03-08 14:06:34

    text-align:center;