2012-10-10 130 views
2

可能重複:
Why don't margin-top: auto and margin-bottom:auto work the same as their left and right counterparts?
What is the rationale behind margin-top: auto and margin-bottom: auto amounting to 0 margin?保證金:汽車自動

爲什麼不margin: auto auto;加垂直居中? auto關鍵字不應該告訴瀏覽器在頂部和底部之間平均分配邊距嗎?我的印象是它對左右利潤的影響。

+0

主要問題是開放式的。關於SO和圍繞Web的垂直居中元素有很多討論。 –

+0

@BoltClock,任何你沒有關閉的原因? – zzzzBov

+0

@zzzzBov尚未達5分鐘。 –

回答

4

歸根結底這是一個W3C規範 -

如果「邊距」或「下邊距」爲「自動」,他們使用的值是0

它似乎像這將是方便的。

0

auto關鍵字應做任何在w3c spec定義,這恰好是:

如果「邊距」或「邊距」是「自動」,其使用的值是0 。