0

I have 5 divs. Each time I want only one of them to be shown in the middle of the screen. The problem is that the hidden divs takes space. Each div contain a lot of information so I don't want to create it each time I need to show it.

I simply used: visibility="visible" or visibility="hidden".

Are there other possibilities?

4

4 回答 4

3

您需要使用display:none从布局中完全隐藏元素,这被记录为:

none - 此值导致元素不出现在文档中。它对布局没有影响。

visibility:hidden会留下一个看不见的盒子,这就是你遇到的问题。从文档中:

hidden - 生成的框是不可见的(完全透明,没有绘制任何内容),但仍会影响布局。此外,如果元素的后代具有“可见性:可见”,则它们将是可见的。

a的默认 CSSdisplay<div>display:block,所以要再次显示<div>只需将元素设置回display:block. 请注意,还有其他值display,因此请注意将其设置回原始值(可能不一定是默认值)。

于 2013-05-09T13:56:39.333 回答
0

use display:none if you use css or .hide() if you use jquery

于 2013-05-09T13:57:26.920 回答
0

I would normally just use the jquery 'hide' method. This should hide the div's without them taking up any space on the screen.

于 2013-05-09T13:57:31.043 回答
0

Even invisible elements take up space on the page. Use the display property to create invisible elements that do not take up space.

display:none;

Read this for more info --> https://developer.mozilla.org/en-US/docs/CSS/display

于 2013-05-09T13:57:38.240 回答