Web/API/ScrollToOptions/left

From Get docs

The left property of the ScrollToOptions dictionary specifies the number of pixels along the X axis to scroll the window or element.


Syntax

left: double

Value

A double.

Examples

In our scrolltooptions example ([[../../../../../../../mdn.github.io/dom-examples/scrolltooptions/index|see it live]]) we include a form that allows the user to enter three values — two numbers representing the left and top properties (i.e. the positions to scroll to along the X and Y axes), and a checkbox indicating whether they want smooth scrolling enabled or not.

When the form is submitted, an event handler is run that puts the entered values into a ScrollToOptions dictionary, and then invokes the Window.ScrollTo() method, passing the dictionary as a parameter:

form.addEventListener('submit', (e) => {
  e.preventDefault();
  var scrollOptions = {
    left: leftInput.value,
    top: topInput.value,
    behavior: scrollInput.checked ? 'smooth' : 'auto'
  }

  window.scrollTo(scrollOptions);
});

Specifications

Specification Status Comment
CSS Object Model (CSSOM) View ModuleThe definition of 'left' in that specification. Working Draft  

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
left Chrome

Full support 45

Edge

Full support 79

Firefox

Full support Yes

IE

No support No

Opera

Full support 32

Safari

Full support Yes

WebView Android

Full support 45

Chrome Android

Full support 45

Firefox Android

Full support Yes

Opera Android

Full support 32

Safari iOS

Full support Yes

Samsung Internet Android

Full support 5.0

Legend

Full support  
Full support
No support  
No support


See also

ScrollToOptions