Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

css

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;}?

like image 652
kat Avatar asked Feb 21 '10 14:02

kat


People also ask

How do you hide an element in CSS without affecting the layout?

You can hide an element in CSS using the CSS properties display: none or visibility: hidden . display: none removes the entire element from the page and mat affect the layout of the page.

How do I hide a div but keep the space?

you can wrap another div around the outside of it, and probably tell it a specific height to occupy. that way your inner div can show and hide and fadeOut, etc, and the outer div will hold down the real-estate on the page.


1 Answers

visibility: hidden 

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

like image 150
Jamie Dixon Avatar answered Sep 28 '22 05:09

Jamie Dixon