可见性:隐藏的反面是可见性:可见。同样地,是否有相反的显示:没有?
当一个元素有display: none时,许多人都搞不清楚如何显示它,因为它不像使用visibility属性那么清楚。
我可以只使用visibility: hidden而不是display: none,但它不会产生相同的效果,所以我不会使用它。
可见性:隐藏的反面是可见性:可见。同样地,是否有相反的显示:没有?
当一个元素有display: none时,许多人都搞不清楚如何显示它,因为它不像使用visibility属性那么清楚。
我可以只使用visibility: hidden而不是display: none,但它不会产生相同的效果,所以我不会使用它。
当前回答
我在构建一个应用程序时遇到了这个挑战,我想要为某些用户隐藏一个表,而不是为其他用户隐藏。
最初,我将它设置为display:none,但后来为那些我希望看到它的用户设置了display:inline-block,但我遇到了您可能期望的格式问题(列合并或通常混乱)。
我解决这个问题的方法是先显示表,然后为那些我不想看到它的用户执行“display:none”。这样,它可以正常格式化,但在需要时消失。
这是一个横向的解决方案,但可能会帮助到某些人!
其他回答
在打印机友好的样式表的情况下,我使用以下:
/* screen style */
.print_only { display: none; }
/* print stylesheet */
div.print_only { display: block; }
span.print_only { display: inline; }
.no_print { display: none; }
I used this when I needed to print a form containing values and the input fields were difficult to print. So I added the values wrapped in a span.print_only tag (div.print_only was used elsewhere) and then applied the .no_print class to the input fields. So on-screen you would see the input fields and when printed, only the values. If you wanted to get fancy you could use JS to update the values in the span tags when the fields were updated but that wasn't necessary in my case. Perhaps not the the most elegant solution but it worked for me!
我使用 显示:块; 这对我很有用
Display:unset将其设置回初始值,而不是之前的“Display”值
我只是复制了之前的显示值(在我的情况下display: flex;) 再次(在display non之后),并且它过度尝试了display:none成功
(我使用display:none来隐藏移动和小屏幕的元素)
在使用react native时,与“none”相对的是“flex”。
你可以使用这个display:block;并同时添加overflow:hidden;