オフセット()。トップとscrollTopスプライト()

1.offset()。トップ)(文書の整合素子の位置に対してオフセット

< 本体> 
    < スタイルタイプ= "テキスト/ CSS" > { 
            ボーダー20ピクセル固体#CCC 
            マージン10pxの; 
            パディング40ピクセル; 
            背景#EEE 
        } 
        #test { 400ピクセル
            高さ200pxの
            パディング40ピクセル; 
            背景#のF60; 
            ボーダー5pxの固体#888 ; 
        } 
    </ スタイル> 
    < DIV ID = "テスト" > </ DIV > 
    < スクリプト> 
        VAR テスト= のdocument.getElementById(" 試験" )。
        test.innerHTML =  " <P>ブラウザ:"  + navigator.userAgent +  " </ P> "  + 
            " <P> offsetWidth:"  + test.offsetWidth +   + 
            " <P> offsetHeight:" + test.offsetHeight + " </ P> " + 
            " <P> offsetLeft:" + test.offsetLeft + " </ P> " + 
            " <P> offsetTop:" + test.offsetTop + " </ P> " ;
    </ スクリプト> 
</ ボディ>

2.scrollTop()

(かかわらず、スクロールバーの長さのスクロールバーの上部)マッチング要素垂直スクロール位置

おすすめ

転載: www.cnblogs.com/love-dream-88/p/11434292.html
おすすめ