Changing scroll speed in Firefox using CSS

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam fringilla, turpis eget vestibulum vulputate, enim orci tempor enim, vel consectetur ipsum orci sit amet enim. Aliquam nec viverra justo. Pellentesque viverra cursus quam eget maximus. Nullam iaculis mauris leo, et pharetra nisi ultricies in. Mauris varius hendrerit nulla, quis aliquet sapien. Pellentesque eu ultrices nibh. Nunc mollis porta tincidunt. Praesent risus nibh, vestibulum eu gravida et, dignissim eu velit. Mauris quis iaculis mauris.

Nulla facilisi. Suspendisse malesuada tortor sed augue tempor sodales vitae vitae felis. Suspendisse urna nunc, luctus sit amet libero et, vestibulum pellentesque sem. Vivamus mollis felis id nisi ultricies, vitae lacinia est egestas. Pellentesque quis quam non dolor ultricies pulvinar. Nunc sodales diam tristique pharetra vehicula. Fusce consequat eu turpis vitae consequat. Ut aliquet sem felis, vel venenatis mi commodo a. Donec volutpat egestas enim, at vestibulum ligula vestibulum eget. Nunc facilisis ex felis, et fermentum arcu pellentesque sed. In molestie eros nec metus molestie iaculis. Cras eu sem consectetur ex consequat blandit at auctor lacus. In finibus dolor vitae leo dignissim, non egestas dolor consectetur. Vestibulum sit amet sem sit amet nulla dignissim rhoncus sed nec est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam fringilla, turpis eget vestibulum vulputate, enim orci tempor enim, vel consectetur ipsum orci sit amet enim. Aliquam nec viverra justo. Pellentesque viverra cursus quam eget maximus. Nullam iaculis mauris leo, et pharetra nisi ultricies in. Mauris varius hendrerit nulla, quis aliquet sapien. Pellentesque eu ultrices nibh. Nunc mollis porta tincidunt. Praesent risus nibh, vestibulum eu gravida et, dignissim eu velit. Mauris quis iaculis mauris.

Nulla facilisi. Suspendisse malesuada tortor sed augue tempor sodales vitae vitae felis. Suspendisse urna nunc, luctus sit amet libero et, vestibulum pellentesque sem. Vivamus mollis felis id nisi ultricies, vitae lacinia est egestas. Pellentesque quis quam non dolor ultricies pulvinar. Nunc sodales diam tristique pharetra vehicula. Fusce consequat eu turpis vitae consequat. Ut aliquet sem felis, vel venenatis mi commodo a. Donec volutpat egestas enim, at vestibulum ligula vestibulum eget. Nunc facilisis ex felis, et fermentum arcu pellentesque sed. In molestie eros nec metus molestie iaculis. Cras eu sem consectetur ex consequat blandit at auctor lacus. In finibus dolor vitae leo dignissim, non egestas dolor consectetur. Vestibulum sit amet sem sit amet nulla dignissim rhoncus sed nec est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.

(live demo - compare scrolling speeds in Firefox)

For quite a while now, a thing that bugged me in Firefox was the inconsistent scrolling speeds across the pages. On some it would seem just fine, while on others you could have a list that scrolls at a ridiculously slow pace. My searches on the subject were inconclusive - while, of course, you can regulate the scroll speed via scripting, that definitely wasn't the case on all these pages.

The culprit, as it turns out, was pretty simple - while most of the browsers scroll the elements for an amount of (screen) pixels per key press or mouse wheel change, Firefox scrolls the elements based on the their font size. Which, on one hand, makes sense, but there's a catch - it's based only on the scrolling element's font size. Content' font sizes are ignored.

So that is why you get odd scrolling speeds - people most often set up styles for the actual content (paragraphs\labels\etc.) and not the scroller\container element.

Luckily, this also means that scrolling speeds can be adjusted easily - you change the container font-size to (100*X)%, and then add a rule to change it's child element sizes to (100/X)%:

.fastscroll { /* overflow'ing element */
	font-size: 400% /* 4x faster scroll */;
}
.fastscroll > * {
	font-size: 25%;
}

Visually nothing will change (since the sizes "balance out"), but the scrolling speed will change in Firefox (to reflect the increased scrollable element' font size).

Quite pleasantly, this approach can also be used in "userstyles", meaning that you can easily adjust the scrolling speed of any pages to one that feels appropriate.

Have fun!

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.