Customize scroll bar above page content?

I wonder if there is a way, via css or javascript, to make the scroll bar appear on top of the contents of the website (e.g. z-index 9999) instead of moving all the elements to the left? My design includes blank space on the left, regardless of screen resolution or size, so this will not be a problem compared to constantly moving left / right overlaid by the scrollbar when it appears / disappears.

If not, I will just use the overflow-y: scroll method, but another solution would be nice if possible :)

Thanks for your reply!

+4
source share
1 answer

"" ... , , - , . , , , js jquery.

, , . , :

// If there is no scrollbar, add some padding to replace it.
if ($(document).height() > $(window).height()) {
    $('body').css('padding', 'none');
} else {
    $('body').css('padding', '0 '+scrollbarwidth+'px 0 0');
}

. jsfiddle .

. , . , . , - , .

0

All Articles