Elliott Coe
Elliott Coe

Reputation: 543

How to stop expanding html elements from scrolling the page?

I have an div which contains some text which has it's opacity set to 0 and visibility set to hidden, but when another element is clicked, the opacity goes to 1 and the visibility is visible, but this causes the page to scroll a small amount rather than the expanded content just pushing the content below it down and making the page longer. How can I solve this?

Upvotes: 1

Views: 696

Answers (1)

Tygo
Tygo

Reputation: 192

When an element's visibility is set to hidden the element is still there its just transparent. But the extra space will stay. By changing visibility: hidden to display: none the element is totally hidden and won't take extra space. Check this post for a better explanation: StackOverflow

Upvotes: 2

Related Questions