Gurebu Bokofu Gurebu Bokofu - 1 month ago 12
HTML Question

How to hide the DOM-element at the left of the <body> without horizontal scrollbar will appear?

Consider below

jQuery
script:

$("#right").click(function(){
$(".block").animate({"left": "+=50px"}, "slow");
});

$("#left").click(function(){
$(".block").animate({"left": "-=50px"}, "slow");
});


(source: jqbook)

enter image description here

This script allows to move the square to the left and to the right by buttons.
If we move the square out of to left, the horizontal scrollbal will not apper, however it will even if we define
width
for
body
and move the square to the right of the body canvas.

Could I move the DOM element to the right of the body without the horizontal scrollbar will appears?

Note: this problem is actulal for hamburger-menu. No problem if to hide it at the left of body(simple example in russian but you need code only), but how to hide the menu in the right of the body without scrollbar will appears?

Answer

Yes, you could do it. You can just simply add a CSS rule.

body{
   overflow:hidden;
}
Comments