开发者社区> 问答> 正文

padding:0 auto;不能使内容居中呢?

想设置一个div居中,使用padding:0 auto;width:1000px;
为什么不能是元素居中呢?
因为使用margin:0 auto;的话,居中的两边背景色会用空白·

展开
收起
杨冬芳 2016-06-01 17:14:19 3083 0
1 条回答
写回答
取消 提交回答
  • IT从业

    If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element with respect to the edges of the containing block.

    然后在http://www.w3help.org/有一篇类似相关的文章,不知道是否能帮你 http://www.w3help.org/zh-cn/causes/RD8028

    2019-07-17 19:23:34
    赞同 展开评论 打赏
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载