mozilla
Your Search Results

    Element.scrollTop

    The Element.scrollTop property gets or sets the number of pixels that the content of an element is scrolled upward. An element's scrollTop is a measurement of the distance of an element's top to its topmost visible content. When an element content does not generate a vertical scrollbar, then its scrollTop value defaults to 0.

    Syntax

    // Get the number of pixels scrolled
    var  intElemScrollTop = someElement.scrollTop;
    

    After running this code, intElemScrollTop is an integer corresponding to number of pixels that the element's content has been scrolled upward.

    // Set the number of pixels scrolled
    element.scrollTop = intValue;
    

    scrollTop can be set to any integer value, with certain caveats:

    • If the element can't be scrolled (e.g. it has no overflow or if the element is non-scrollable), scrollTop is set to 0.
    • If set to a value less than 0, scrollTop is set to 0.
    • If set to a value greater than the maximum that the content can be scrolled, scrollTop is set to the maximum.

    Example

    padding-top

    Gentle, individualistic and very loyal, Birman cats fall between Siamese and Persian in character. If you admire cats that are non aggressive, that enjoy being with humans and tend to be on the quiet side, you may well find that Birman cats are just the felines for you.

    Image:BirmanCat.jpgAll Birmans have colorpointed features, dark coloration of the face, ears, legs and tail.

    Cat image and text coming from www.best-cat-art.com

    padding-bottom

    LeftTopRightBottommargin-topmargin-bottomborder-topborder-bottom[if IE]><span id="MrgLeft" style="position: _fckstyle="position: absolute; left: 8px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">margin-left</span><span id="BrdLeft" style="position: absolute; left: 33px; top: 65px; color: white; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">border-left</span><span id="PdgLeft" style="position: absolute; left: 55px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">padding-left</span><span id="PdgRight" style="position: absolute; left: 275px; top: 60px; color: black; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl; white-space: nowrap;">padding-right</span><span id="BrdRight" style="position: absolute; left: 310px; top: 65px; color: white; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">border-right</span><span id="MrgRight" style="position: absolute; left: 340px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">margin-right</span><![endif]

    Image:scrollTop.png

    Specifications

    Specification Status Comment
    CSS Object Model (CSSOM) View Module
    The definition of 'scrollTop' in that specification.
    Working Draft  

    References

    Hide Sidebar