可见性:隐藏的反面是可见性:可见。同样地,是否有相反的显示:没有?
当一个元素有display: none时,许多人都搞不清楚如何显示它,因为它不像使用visibility属性那么清楚。
我可以只使用visibility: hidden而不是display: none,但它不会产生相同的效果,所以我不会使用它。
可见性:隐藏的反面是可见性:可见。同样地,是否有相反的显示:没有?
当一个元素有display: none时,许多人都搞不清楚如何显示它,因为它不像使用visibility属性那么清楚。
我可以只使用visibility: hidden而不是display: none,但它不会产生相同的效果,所以我不会使用它。
当前回答
恢复到原来的状态put:
display=""
其他回答
我在构建一个应用程序时遇到了这个挑战,我想要为某些用户隐藏一个表,而不是为其他用户隐藏。
最初,我将它设置为display:none,但后来为那些我希望看到它的用户设置了display:inline-block,但我遇到了您可能期望的格式问题(列合并或通常混乱)。
我解决这个问题的方法是先显示表,然后为那些我不想看到它的用户执行“display:none”。这样,它可以正常格式化,但在需要时消失。
这是一个横向的解决方案,但可能会帮助到某些人!
在使用react native时,与“none”相对的是“flex”。
你可以使用
display: normal;
它正常工作....这是css的一个小黑客;)
就像Paul解释的那样,没有与显示相反的文字:在HTML中没有,因为每个元素都有不同的默认显示,你也可以用类或内联样式等改变显示。
However if you use something like jQuery, their show and hide functions behave as if there was an opposite of display none. When you hide, and then show an element again, it will display in exactly the same manner it did before it was hidden. They do this by storing the old value of the display property on hiding of the element so that when you show it again it will display in the same way it did before you hid it. https://github.com/jquery/jquery/blob/740e190223d19a114d5373758127285d14d6b71e/src/css.js#L180
这意味着如果你将一个div设置为显示内联或内联块,然后隐藏它,然后再次显示它,它将再次显示为显示内联或内联块,就像之前一样
<div style="display:inline" >hello</div>
<div style="display:inline-block">hello2</div>
<div style="display:table-cell" >hello3</div>
脚本:
$('a').click(function(){
$('div').toggle();
});
请注意,即使div被隐藏(display:none)并再次显示之后,它的显示属性也将保持不变。
你可以使用这个display:block;并同时添加overflow:hidden;