Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

translateY/X causing scrollbars in Firefox

When using translateX or translateY, the layout of the page on Firefox appears to be affected. Persistent scrollbars are generated, even though the CSS specification states that these properties shouldn't affect layout.

For an example, go to http://daneden.me/animate and click the 'fadeOutRightBig' animation. scrollbars will be generated on all browsers (that support CSS animations) but will persist in Firefox. Is this down to a mistake by Mozilla or by the other browsers? Any known solution?

like image 220
Dan Eden Avatar asked Oct 14 '11 14:10

Dan Eden


People also ask

How do you find out what is causing horizontal scroll?

To find out which elements cause a horizontal scrollbar, you can use the devtools to delete elements one by one until the scrollbar disappears. When that happens, press ctrl/cmd Z to undo the delete, and drill down into the element to figure out which of the child elements cause the horizontal scrollbar.

How do I turn off horizontal scrollbar in Firefox?

Chosen solution If you hide the scrollbar with root{ scrollbar-width: none } then this hides all the scroll bars and you can't differentiate. Styling scrollbars with userChrome.

Why does my website have a vertical scrollbar?

Logically the reason you're getting a vertical scrollbar is that the browser interprets the content to have a height which is bigger then the height of container... in this case you're having vertical margins which overflow and are not being cleared; here's a fiddle resetting to margin:0 and the overflow-Y disappeared.


3 Answers

Another way to solve this problem is to switch to fixed positioning:

#EvilElement {
    position: fixed;
}

Of course this may have other side-effects, but it won't disable horizontal scrollbars for the whole page.

like image 70
Torben Avatar answered Sep 18 '22 15:09

Torben


Looks like a bug to me: https://bugzilla.mozilla.org/show_bug.cgi?id=456497 but it's weird it hasn't gotten attention, seems pretty serious to me.

The solution, if you can get away with it, would be hiding the horizontal overflow on the html element:

html {
  overflow-x: hidden;
}

Or if you need horizontal scrolling, apply it on the parent element.

like image 21
methodofaction Avatar answered Sep 21 '22 15:09

methodofaction


A comment on the Bugzilla issue makes a good point: this is the same behavior as position: relative. The original element's place is retained, but if the transformed element moves outside of it's viewable container (the viewport or scrollable element), scrollbars are added.

This conforms to the spec and most likely will be "won't fix".

like image 35
RobW Avatar answered Sep 19 '22 15:09

RobW