覆盖父级的CSS显示属性 [英] Overriding parent's CSS display property

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

问题描述

我理解如何覆盖父样式,我知道这个例子是有设计的,但是有一种方法(使用内联CSS),导致孩子跨度显示,即使其父设置为无显示吗?

I understand how to override parent styles, and I know this example is contrived, but is there a way (with inline CSS) to cause the child span to show, even though its parent is set to no display?

<span style="display:none">
<span style="display:block;">Test</span>
</span>


推荐答案

简答:不。

长回答:如果父级隐藏,则无法覆盖子级中的显示。您可以使用JavaScript从其父级中删除子范围,并将其放置在您可以应用显示样式的主体中。像显示,不透明度,可见性等的效果影响他们应用的元素的子元素,效果不能完全对抗,但对于像opacity这样的东西,他们可以添加到。

Long answer: There is no way to override display in children if the parent is hidden. You could use JavaScript to remove the child span from its parent, and place it in the body where you can apply a display style. Things like display, opacity, visibility etc, effect the children of elements they are applied to, the effects can't be completely countered, but for things like opacity they can be added to.

这篇关于覆盖父级的CSS显示属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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