--- title: element.scrollTop slug: Web/API/Element/scrollTop tags: - Référence_du_DOM_Gecko translation_of: Web/API/Element/scrollTop ---

{{ ApiRef() }}

Résumé

Définit ou obtient le nombre de pixels dont le contenu de l'élément a défilé vers le haut.

Syntaxe

// Obtient le nombre de pixels défilés
var  intElemScrollTop = element.scrollTop;

intElemScrollTop est un entier correspondant au nombre de pixels dont le contenu d'element a défilé vers le haut.

// Définit le nombre de pixels défilés
element.scrollTop = intValue;

scrollTop peut avoir n'importe quelle valeur entière, cependant :

Description

L'attribut scrollTop d'un élément est la mesure de la distance entre le haut de cet élément et le point le plus haut de son contenu visible.

Lorsqu'un élément ne génère pas de barre de défilement vertical, sa valeur scrollTop vaut 0.

Exemple

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{{ mediawiki.external('if IE') }}><span id="MrgLeft" style="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><!{{ mediawiki.external('endif') }}

Image:scrollTop.png

Il n'est pas possible d'avoir une démonstration interactive dans cette référence.

Spécification

scrollTop fait partie du modèle objet DHTML de Microsoft Internet Explorer. Elle ne fait partie d'aucune spécification ou recommandation technique du W3C.

Notes

scrollTop est une propriété du modèle objet DHTML provenant de Microsoft Internet Explorer. On l'appelle la distance entre le haut physique d'un élément et son affichage défilant.

Références

{{ languages( { "en": "en/DOM/element.scrollTop", "pl": "pl/DOM/element.scrollTop" } ) }}