Safariã®ä½ç½®ã«é¢ããããããã£ã¾ã¨ã
æè¿ãSafariä¸ã§Javascriptãçµããã¨ãå¤ãæã£ã¦ããã®ã§ã³ã¬ãæ©ã«ææ¡ãããã¦ããªãä½ç½®é¢é£ã®ããããã£ãã¾ã¨ãã¦ã¿ããã¨ã«ãã¾ãã.
ã¯ããã«
- åä½ã¯å ¨ã¦pxã§çµ±ä¸
- éåã®ããããã£ã¯DOM(æ¨æºã§ã¯ãªã)é¢é£ã®ããããã£
- ç·åã®ããããã£ã¯CSSé¢é£ã®ããããã£
CSSé¢é£ã®ããããã£ã«ã¯åä½ãå«ã¾ãã¾ããpxã§çµ±ä¸ãã¦ããã®ã§è¡¨è¨ä¸çç¥ãã¦ãã¾ã.
DOMé¢é£ã®ããããã£ã¯document.getElementById('id')çã§åå¾ãããªãã¸ã§ã¯ãã®ããããã£ã§ã.
CSSé¢é£ã®å¤ã®åå¾ã¯document.defaultView.getComputedStyle(elem,null)ã§åå¾ãããªãã¸ã§ã¯ãã®ããããã£ã使ãã¨å®éã«è¡¨ç¤ºããã¦ããå¤ãåå¾ã§ãã¾ã.ããããã£åã«ã¯ãã£ã¡ã«ã±ã¼ã¹(LCC)ã§åç §ã§ãã¾ã.
border,margin,paddingé¢é£
ä¾ãã°divè¦ç´ ã ã¨ãã¦ä»¥ä¸ã®ããã«è¦ããã¨ã·ã³ãã«ï¼
- borderãå«ããé·ããoffsetXxxã§åå¾(Width/Height)
- borderãå«ããªãé·ããclientXxxåã¯scrollXxxã§åå¾(Width/Height)
- ä¸ä¸å·¦å³ã®borderã¯clientXxxã§åå¾(Top/Right/Bottom/Left)
ã¹ã¯ãã¼ã«æã®å¤
ç´ä¸ã®åè¦ç´ ã«ãã£ã¦ãæåãéãã¾ã.
ã©ããã¦+4ã¨ã0ã¨ãã«ãªã£ã¦ããã®ãããã¥ã¡ã³ããè¦ã¤ããã¾ããã§ããããäºå®è¨ç®æ¹æ³ãéãããã§ã.試ããã®ã¯imgã¨divã ãã§ãããä»ã«ãåæ§ã®äºè±¡ãããã¨ãããã¾ã.
ã¹ã¯ãã¼ã«ãã¼ãç¡ãå ´åã¯scrollWidth/scrollHeightã¯ãããããclientWidth/clientHeightã¨åãããªãã¾ã.
è¦ç´ ã®ä½ç½®
ãã®ä¾ã ã¨divè¦ç´ ã®ï¼ã¤éãã¦ãã¾ã.
ä¾ã®offsetTopã®ç®åºæ¹æ³ã¯ä»¥ä¸ã®ããã«ãªãã¾ãã
offsetTop = å¤å´è¦ç´ (pading-top) + ä¸éè¦ç´ (margin-top + border-top + padding-top) + å å´è¦ç´ (margin-top)
25 = 5 + 5 + 5 + 5 + 5
è¦ç´ ã®borderã®å¤å´ããpositionãstatic以å¤ã®è¦ªè¦ç´ ã®borderã®å
å´ã¨ã®ç¸å¯¾è·é¢ãoffsetTop/offsetLeftã§åå¾ã§ãã¾ã.
åºæºã¨ãªã親è¦ç´ ã¯offsetParentã§åå¾ã§ãã¾ã.
å ã«htmlè¦ç´ ã¨ãbodyè¦ç´ ã¯position:staticã§ã.