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?
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.
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.
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.
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.
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With