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

盒模型中,如何设置文字在边框中间


div{border:1px dotted red;weight:100px;height:100px}

假设这个div中间有“盒子”两个字,如何补充以上代码让“盒子”这两个字完全居中?就是上下左右距离边框的距离都一样

提问者:前端周 2016-07-16 14:16

个回答

  • 慕勒2699229
    2016-07-16 14:29:05
    已采纳

    margin-left:auto;

    margin-right:auto;

  • 慕粉3664120
    2016-07-20 13:22:15

    div{

    border:1px dotted red;

    weight:100px;

    height:100px;

    margin:0px auto;

    }