JavaScript Overflow: hidden but i still want to have the empty scrollbar overflow hidden still scrolls,overflow hidden still takes up space,

I set 'overflow:hidden' on my html body with Javascript when I press a button. But when I do that the whole body moves 5 pixels or so to the left because the space of the scrollbar is gone. How do i prevent that.

I can't set margin of the body to a specific size because the width of scrollbars differentiate between browsers

Answer:1

You could try this old trick:

html {
  overflow-y: scroll; 
}

What this does is force the scrollbar to always be visible.

Compare:

normal JSFiddle

JSFiddle with the vertical scrollbar always there

Answer:2

Here is code to add a disabled vertical scroll bar. If placed more prominent in CSS than the rest of the CSS, it should override whatever you've done to other portions.

html {
overflow-y: scroll;
}
Answer:3

I use django-swampdragon + angularjs to create simple django app which shows website requests in real-time. All of the Django logic is okay, but when I try make it respond in real-time the system ...

I use django-swampdragon + angularjs to create simple django app which shows website requests in real-time. All of the Django logic is okay, but when I try make it respond in real-time the system ...

I am trying to read the ID3 tags of an music file. Currently i have a Dataview object with the last 128 bits of an audio file in it (because the ID3 tags are at the last 128 bits in a audio file). So ...

I am trying to read the ID3 tags of an music file. Currently i have a Dataview object with the last 128 bits of an audio file in it (because the ID3 tags are at the last 128 bits in a audio file). So ...

  1. javascript dataview read string

I am using javascript to create html page , but not able to call some function on button click . var alernative = "plot1"; var buttonvalue= "mybutton"; function callme() {alert("hello");} $('#'...

I am using javascript to create html page , but not able to call some function on button click . var alernative = "plot1"; var buttonvalue= "mybutton"; function callme() {alert("hello");} $('#'...

  1. calling function from another file python
  2. calling function from another script unity
  3. calling function from another file matlab
  4. calling function from another function in python
  5. calling function from another class c++
  6. calling function from header file c++
  7. calling function from class c++
  8. calling function from another file javascript
  9. calling function from class python
  10. calling function from dictionary python
  11. calling function from another class
  12. calling function from another file in c
  13. calling function from another class java
  14. calling function from another class python
  15. calling function from another file php
  16. calling function from html angular
  17. calling function from external js file
  18. calling function from main java
  19. calling function from html
  20. calling function from another component react

simple javascript but can't seem to get it to work. var number = 5; var netiteration = "net"+number; // makes netiteration now equal net5 var formvalue = document.forms.myformname.netiteration....

simple javascript but can't seem to get it to work. var number = 5; var netiteration = "net"+number; // makes netiteration now equal net5 var formvalue = document.forms.myformname.netiteration....

  1. javascript form value by name
  2. javascript form value set
  3. javascript form value get
  4. javascript form value
  5. javascript form value change
  6. javascript form value length
  7. javascript form value array
  8. javascript form value check
  9. javascript form value by id
  10. javascript form value clear
  11. javascript form value select
  12. javascript form value empty
  13. javascript form value validation
  14. javascript form value to variable
  15. javascript form value checkbox
  16. javascript form value update
  17. javascript value form dropdown
  18. javascript form input value
  19. javascript change form value before submit
  20. javascript form field value