为什么不能覆盖通过星号应用的显示属性? [英] Why can't I override display property applied via an asterisk?
本文介绍了为什么不能覆盖通过星号应用的显示属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想以某种屏幕分辨率隐藏所有元素,只显示想要显示的元素:
I want to hide all the elements in some screen resolution and just show the wanted element to be visible:
例如:
*{
display: none;
}
#block{
display: block !important;
}
但这不会再覆盖display属性. 演示
But this won't override the display property anymore. demo
推荐答案
*
定位文档中的所有元素,包括html
和body
.这就是为什么内容仍处于隐藏状态的原因-验证这一点.
*
targets all elements within the document, including html
and body
as well. That's why the content is still hidden - verify that.
如果要选择<body>
中的所有元素,则应按以下步骤操作:
If you want to select all elements within the <body>
you should do that as follows:
body * {
display: none;
}
#block {
display: block;
}
<div id="block">block</div>
这篇关于为什么不能覆盖通过星号应用的显示属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文