gpt4 book ai didi

css - 纯 CSS。子元素的可见性取决于父类。是否可以?

转载 作者:行者123 更新时间:2023-12-04 21:41:08 25 4
gpt4 key购买 nike

我能否通过纯 CSS 实现此行为:如果父 block 具有“隐藏”类,则具有“a”类的子元素必须是不可见的

例子

<div class="parent">
<div class="a"></div> // Visible
<div class="b"></div> // Visible
</div>

<div class="parent hidden">
<div class="a"></div> // Invisible
<div class="b"></div> // Visible
</div>

最佳答案

试试这个

 .parent.hidden .a 
{
///display: none;
}

注意:

visibility:hidden hides an element, but it will still take up the same space as before. The element will be hidden, but still affect the layout.

display:none hides an element, and it will not take up any space. The element will be hidden, and the page will be displayed as if the element is not there

关于css - 纯 CSS。子元素的可见性取决于父类。是否可以?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20042018/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com