[css]margin-topのパーセンテージの属性値

530 ワード

学習ノート
  • always relative to the width of the containing block.

  • padding-top,padding-bottom同様に、一般的に容器要素の幅で計算されるのはなぜですか???最初はレイアウトのため、上下左右が同じであることを保証し、同じ値を参照してこそ、同じパーセンテージが同じになります.top:50%;margin-top:-50%; trick , 。を使って
  • でも絶対的ではありません.writing-modeを縦書きに設定した場合、例えば-webkit-writing-mode:vertical-lr;このときパーセントで書かれたmarginは容器の高さを参照して計算されます.

  • 参考文献
  • MDN: margin-top
  • marginシリーズのパーセント
  • CSSのmargin-top/bottom(padding-top/bottom)の割合は、なぜ高さではなく最近のブロックレベルの祖先要素の幅で計算されますか?