タグの座標

記事
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) 

サービス数40万件のスキルマーケット、あなたにぴったりのサービスを探す ココナラコンテンツマーケット ノウハウ記事・テンプレート・デザイン素材はこちら