>>607
ボックスモデルと同じ計算を実装すればいい
https://developer.mozilla.org/ja/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model