Looking for a CSS Solution:
Is there a way to achieve element.scrollLeft functionality in CSS without using javascript? I want to pre-scroll a scrollable container.
Situation Overview:
I have a scrollable container that houses various items. Some instances of this container may overflow, and I would like the scroll offset to automatically be positioned at the end.
https://i.stack.imgur.com/iTmUu.jpg
The Teaser:
While I currently use javascript to manipulate the scroll position effectively, there is a perceptible jitter or sudden movement within the scrollable content. Can anyone suggest a pure CSS technique to preset the scroll position?
Check out Code Sandbox for sample code: https://stackblitz.com/edit/js-9b9wt5?file=index.html
const cardContainerEls = document.querySelectorAll('.card-container');
cardContainerEls.forEach((el) => {
el.scrollLeft = 1000;
});