You cannot get the dimensions or position of a DOM element with display:none. By definition, an element should not exist on the page, so it does not take up space.
I suggest that you first leave your element visible, having the desired dimensions, and then applying the " display:none" after you do it.
Alternatively, you can use <instead visibility:hidden.
source
share