“margin:0 auto”之间是否存在任何差异;和“margin:auto”;

编程入门 行业动态 更新时间:2024-10-26 16:23:45
本文介绍了“margin:0 auto”之间是否存在任何差异;和“margin:auto”;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我们想要页面的主容器对齐中心时,我们通常使用margin:0 auto;,但是当我使用 ;的行为在某些浏览器中是一样的(Google Chrome,Firefox)。

When we want page's main container align center, we usually use "margin: 0 auto;", but when I use "margin:auto;", behaviour are the same in some browser I have (Google Chrome, Firefox).

推荐答案

>是的。

margin: 0 auto;

将元素的左右边距设置为 auto ,并将顶部和底部边距设为 0 。

Sets the element's left and right margins to auto, and the top and bottom margins to 0.

margin: auto;

将全部边距设置为 code>。由于< body> 的高度为100%,因此垂直 auto 没有效果。

Sets all the margins to auto. You are probably getting the same behaviour due to your <body> being 100% height, hence the vertical auto margins have no effect.

更多推荐

“margin:0 auto”之间是否存在任何差异;和“margin:auto”;

本文发布于:2023-11-27 15:47:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638626.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:是否存在   差异   margin   auto

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!