如何隐藏元素而不让它们在页面上占用空间? [英] How to hide elements without having them take space on the page?

查看:232
本文介绍了如何隐藏元素而不让它们在页面上占用空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用visibility:hidden隐藏某些元素,但是它们仍然占用页面上的空间,而隐藏。

I'm using "visibility:hidden" to hide certain elements, but they still take up space on the page while hidden.

如何使它们完全在视觉上消失,好像他们根本不在DOM中(但实际上没有从DOM中删除它们)?

How can I make them totally disappear visually, as though they are not in the DOM at all (but without actually removing them from the DOM)?

推荐答案

设置 display:none 可隐藏并设置 display:block 以显示

Try setting display:none to hide and set display:block to show.

这篇关于如何隐藏元素而不让它们在页面上占用空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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