CSS显示:none和visibility:hidden [英] CSS display:none and visibility:hidden

查看:107
本文介绍了CSS显示:none和visibility:hidden的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div,在需要时用来显示警告。

I have a div that I use to display alerts when needed.

如果我想在一段时间后关闭它,我可以使用display:none或者我应该使用显示:none以及visibility:hidden?

If I want to close it after a while can I use display:none or should I use display:none as well as visibility:hidden?

请选择其中一个或两个。

So one or both.

p>

推荐答案

取决于。如果您需要将空格留空,也就是说,该空格不会被下面或其周围的其他元素占用,您需要 visibility:hidden 。否则,使用 display:none ,这将允许其他元素移动到元素的位置。

Depends. If you need the space to be left blank, that is, the space won't be taken up by other elements below or around it, you'll need visibility: hidden. Otherwise, use display: none, which will allow other elements to move into the element's place.

没有理由同时使用。

这篇关于CSS显示:none和visibility:hidden的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆