gpt4 book ai didi

CSS3 : Hiding the parent div when the child div is visible

转载 作者:行者123 更新时间:2023-11-28 07:59:29 25 4
gpt4 key购买 nike

初学者疑惑:想在子div可见的情况下隐藏父div。 这可能与 css 相关吗?也许使用 z-index?

另一件事,我可以用不同的 css 属性格式化子 div,还是它们需要与父 div 相同?谢谢!

<!doctype html>
<style type="text/css">
#intro {
width:100%;
float:left;
padding-top:3%;
background-repeat:no-repeat;
background-size:100%;
position:relative;
z-index:50;
}
.wrapper_intro {
display:block;
width:38%;
margin: 7% 3% 3% 7%;
float:right;
color:black;
padding:3% 3% 4% 3%;
background-color:none;
position:absolute;
z-index:100;
right: 0px;
}
.parent {
display:block;
font-size:5em;
color:yellow;
margin-top: 2%;
margin-bottom:3%;
text-align:center;
z-index: 102;
}
.child {
display:none;
}
.parent:hover .child {
display:block;
background-color: rgba(242, 218, 192, 0.9);
margin-top:5%;
color:black;
text-align:center;
z-index: 101;
}

</style>

      <div class="wrapper_intro">

<div class="parent">
<div>Ola!</div>

<div class="child">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</div>
</div>

最佳答案

当您隐藏父级 div 时,其中的所有元素也将被隐藏。不明白你的情况。如果您希望它们分开,请不要将它们嵌套在一个 div 中。将它们分开。

是的,父项和子项的 css 可以不同。您可以使用 !important 来覆盖父级已经使用的任何 css。

关于CSS3 : Hiding the parent div when the child div is visible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29877068/

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