边距:自动 自动

Usm*_*kil 4 css centering

可能的重复:
为什么 margin-top: auto 和 margin-bottom:auto 的工作方式与左侧和右侧的对应项不同?
margin-top: auto 和 margin-bottom: auto 的保证金为 0 的原理是什么?

为什么不margin: auto auto;添加垂直居中?auto 关键字不应该告诉浏览器将顶部和底部的边距平均分配吗?我的印象是它对左右页边距的作用。

Flu*_*yte 6

最终它是一个 w3c 规范 -

如果 'margin-top' 或 'margin-bottom' 为 'auto',则它们的使用值为 0。

看起来确实会很方便。