8000 Prevent layout jumps on changing overflow hidden to scroll · Issue #6262 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

Prevent layout jumps on changing overflow hidden to scroll #6262

@amir2mi

Description

@amir2mi

This is an obvious one but let me dissect it.

First of all look at the Slack.com sidebar scrollbar, it is pretty great and natural, something that can be done on the web when you know hacks and do some tricks:
CSS: Prevent layout jumps on changing overflow hidden to scroll

Now see the version of browser pure scrollbar that I have made with that:
CSS: Prevent layout jumps on changing overflow hidden to scroll

Here is the simple code of this behavior:

.sidebar{
     overflow: hidden;
}

.sidebar:focus-within,
.sidebar:hover{
     overflow: auto;
}

So when the scrollbar is displayed it is part of its wrapper and adds its width, which causes unwanted layout jumps and shifts other parts.
In contrast, when a modal wants to be shown body overflow should be hidden to prevent the user from scrolling, and here we have another layout jumping again and it is disgusting; there are hacks for this but it is not enough, to be honest.

I wish if we had a feature in CSS to optimize these situations like this:

.sidebar{
     scrollbar-place: beside | over;

     // beside as default
     // 'over' means it does not have any effect on neighbors something like [position: absolute] for elements.
}

In my dreams, I think about pure web scrollbars like native operating system smart scrollbars:
Windows 10 scrollbar in css

I searched about it but it seems there is no native way to handle this situation if there is let me know.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0