It is impossible to know how thick the scrollbar is using only HTML and CSS and therefore does not know the width (blue) of the placeholder.
You can solve this problem using scripts. Set the scroll bar in a hidden container and measure the inner and outer width. The difference is the width of the scroll bar. Set this width (e.g. as CSS) for the placeholder. And in the difficult part, hide this element whenever a scroll bar is displayed.
The usual solution to this problem is the one you do not want.
source share