タグの座標
記事
IT・テクノロジー
x 座標
ボーダー
タグ.getBoundingClientRect().left + window.scrollX
小数精度
コンテンツ
タグ.getBoundingClientRect().left + window.scrollX + ボーダー左 + パディング左
少数精度
y 座標
ボーダー
タグ.getBoundingClientRect().y + window.scrollY
小数精度
コンテンツ
タグ.getBoundingClientRect().top + window.scrollY + ボーダー上 + パディング左
小数精度
幅
ボーダー
タグ.getBoundingClientRect().width
小数精度
パディング
タグ.getBoundingClientRect().width - (ボーダー左 + ボーダー右)
小数精度
コンテンツ
タグ.getBoundingClientRect().width - (ボーダー左 + ボーダー右) - (パディング左 + パディング右)
小数精度
高さ
ボーダー
タグ.getBoundingClientRect().height
小数精度
パディング
タグ.getBoundingClientRect().height - (ボーダー上 + ボーダー下)
小数精度
コンテンツ
タグ.getBoundingClientRect().height - (ボーダー上 + ボーダー下) - (パディング上 + パディング下)
小数精度
ボーダー
左
parseFloat(window.getComputedStyle(タグ).borderLeftWidth)
右
parseFloat(window.getComputedStyle(タグ).borderRightWidth)
上
parseFloat(window.getComputedStyle(タグ).borderTopWidth)
パディング
左
parseFloat(window.getComputedStyle(タグ).paddingLeft)
右
parseFloat(window.getComputedStyle(タグ).paddingRight)
上
parseFloat(window.getComputedStyle(タグ).paddingTop)