8

I'm want to have a div with class "a" to be invisible. I've tried already to give it the display: none; line in the CSS file but what it does is hide it, yet it doesn't catch any space and so all my other boxes don't stay in place.

Is there a way to do this using CSS?

4

3 回答 3

14

add .a{visibility: hidden} to your CSS. More about it here:

http://reference.sitepoint.com/css/visibility

于 2011-06-10T10:58:24.527 回答
2

visibility:hidden should hide the element, while keeping it's space so as not to move your other elements around.

于 2011-06-10T10:59:09.253 回答
1

You can use visibility css property. From sitepoint reference -

This property specifies whether an element is visible—that is, whether the box(es) that are generated by an element are rendered.

Note that even if a box in the normal flow is hidden, it still affects the layout of other elements, unlike the behavior that occurs when we suppress box generation altogether by setting display to none. Descendant boxes of a hidden box will be visible if their visibility is set to visible, whereas descendants of an element for which display is set to none can never generate boxes of their own.

More information can be found here.

于 2011-06-10T11:00:54.223 回答