åå¿é². ã¹ããããçã«ä½¿ã£ã¦ããããã°å¹¸ãã§ã. DOM è¦ç´ ã®çµ¶å¤åº§æ¨ãåå¾ãã element.scrollTop ã¨ãã ã¨è¦ªããã®ç¸å¯¾å¤ã«ãªã£ã¡ããã¾ã. getBoundingClientRect() ã使ãã°çµ¶å¯¾åº§æ¨ãåå¾ã§ãã¾ã. window.onload = function() { var element = document.getElementById('hoge'); // hoge ã¨ããIDãã¤ãããã¤ãåå¾ãã var rect = element.getBoundingClientRect(); console.log(rect.left); // x座æ¨(絶対座æ¨) console.log(rect.top); // y座æ¨(絶対座æ¨) console.log(rect.width); // å¹ console.log(rect.height);


{{#tags}}- {{label}}
{{/tags}}