kat
kat

Reputation: 2075

CSS for hiding a HTML element, keeping its width and height?

I need a CSS snippet for hiding a HTML <div class="my"> (with quite a lot of contents, including text and other divs), but still reserving space for it. Is there something better or faster than div.my{opacity:0;}?

Upvotes: 45

Views: 29756

Answers (2)

Jamie Dixon
Jamie Dixon

Reputation: 54001

visibility: hidden

This will hide the element from the page but retain its place in the layout.

Upvotes: 103

Parth
Parth

Reputation: 529

use document.getElementById("my").style.display = "none"; do not user visibility it only hide element but in display it remove the space acquired by element.

Upvotes: -10

Related Questions