gpt4 book ai didi

html - CSS 选项卡式 Div 不透明度

转载 作者:搜寻专家 更新时间:2023-10-31 23:04:57 24 4
gpt4 key购买 nike

我按照在线教程制作了这个整洁的小选项卡式 div 内容显示,但在设置背景不透明度时我似乎遇到了问题。通过这样做,它揭示了隐藏的内容。我试过在不同的图层上玩耍并设置不透明度,但我没有任何运气。这是一个 example你可以看到。让我知道你们的想法

HTML

    <div class="tabs">
<div class="tab">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab1</label>

<div class="content" id="scrollbar">
<div id="tabcontenttitle"><h1 class="h1titles">title 1</div>
<div id="scrollbar" style="overflow: auto; height: 185px; width: 100%; padding-right: 19px;"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vehicula eu ante nec ultrices. Ut fermentum orci sed quam blandit, ut volutpat nunc pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla massa purus, pellentesque vel tincidunt vitae, adipiscing et dui. Donec imperdiet vestibulum posuere. Sed sed ipsum eget tortor interdum lobortis porta eu nisi. Duis vel purus viverra, congue odio eu, ornare nibh. <br /><br />Vestibulum a congue nisi. Morbi eget magna felis. Donec est nibh, mattis nec faucibus sit amet, dictum at sem. Nulla cursus euismod nunc, scelerisque viverra ligula tempus ac.</p><br />

<p>Nulla facilisi. In nec suscipit quam. In hac habitasse platea dictumst. Phasellus placerat eu augue nec iaculis. Praesent sapien massa, varius nec dolor ac, pulvinar faucibus ipsum. In hac habitasse platea dictumst. Curabitur rhoncus varius leo vel pharetra.</p><br />
<p>Vivamus eget bibendum nulla, vel suscipit arcu. In iaculis, lorem sit amet porta bibendum, mauris purus auctor lorem, in accumsan ipsum massa vel purus. Donec neque justo, posuere sed velit condimentum, tempor elementum arcu. Phasellus rhoncus porta odio et tincidunt. Aliquam facilisis non nisl id molestie. Cras commodo sem ut elementum ultricies. Aliquam gravida, arcu eget vestibulum gravida, leo metus tempor quam, eleifend mollis sapien dui sed justo. </p><br />

<p>Nunc eget odio ac magna facilisis bibendum. Proin eu posuere justo, eu adipiscing arcu. Vivamus et urna accumsan, ultrices diam sed, eleifend odio. Donec consequat lorem nec ipsum scelerisque fermentum.</p></div>

</div>
</div>

<div class="tab">
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Tab2</label>

<div class="content">
<div id="tabcontenttitle"><h1 class="h1titles">title 2</div>
<div id="scrollbar" style="overflow: auto; height: 185px; width: 100%; padding-right: 19px;"> <p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vehicula eu ante nec ultrices. Ut fermentum orci sed quam blandit, ut volutpat nunc pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br /><br />Nulla massa purus, pellentesque vel tincidunt vitae, adipiscing et dui. Donec imperdiet vestibulum posuere. Sed sed ipsum eget tortor interdum lobortis porta eu nisi. Duis vel purus viverra, congue odio eu, ornare nibh. Vestibulum a congue nisi. Morbi eget magna felis. Donec est nibh, mattis nec faucibus sit amet, dictum at sem. Nulla cursus euismod nunc, scelerisque viverra ligula tempus ac.</p><br />
<p> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vehicula eu ante nec ultrices. Ut fermentum orci sed quam blandit, ut volutpat nunc pharetra. Lorem ipsum dolor sit amet, consectetur adipiscing elit. <br /><br />Nulla massa purus, pellentesque vel tincidunt vitae, adipiscing et dui. Donec imperdiet vestibulum posuere. Sed sed ipsum eget tortor interdum lobortis porta eu nisi. Duis vel purus viverra, congue odio eu, ornare nibh. Vestibulum a congue nisi. Morbi eget magna felis. Donec est nibh, mattis nec faucibus sit amet, dictum at sem. Nulla cursus euismod nunc, scelerisque viverra ligula tempus ac.</p><br />
</div>
</div>
</div>

CSS

#scrollbar::-webkit-scrollbar-track
{
-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
background-color: #000;
}

#scrollbar::-webkit-scrollbar
{
width: 12px;
background-color: #F5F5F5;
}

#scrollbar::-webkit-scrollbar-thumb
{
background-color: #cd2429;
}


.tabs {
position: relative;
min-height: 200px; /* This part sucks */
clear: both;
margin-left: 0px;
margin-top: 10px;
}
.tab {
float: left;
}
.tab label {
top: -1px;
font-family: font1;
font-size: 20px;
background: #000;
color: #fff;
padding: 7px;
margin-left: -1px;
position: relative;
left: 1px;
}
.tab [type=radio] {
display: none;
}
.content {
position: absolute;
top: 28px;
left: 0;
right: 0;
bottom: 0;
padding-left: 20px;
padding-right: 20px;
padding-bottom: 20px;
width: 460px; height: 230px;-webkit-border-radius: 5px;
-webkit-border-top-left-radius: 0;
-moz-border-radius: 5px;
-moz-border-radius-topleft: 0;
border-radius: 5px;
border-top-left-radius: 0;color: #fff; background-color: rgba(0,0,0,.6);

line-height: 20px; overflow: hidden; font-family: Tahoma, Geneva, sans-serif; font-size: 12px;
}
[type=radio]:checked ~ label {
background: #cd2429;
z-index: 2;
}
[type=radio]:checked ~ label ~ .content {
z-index: 1;
}

#tabcontenttitle {style="display: block; clear: both; position: relative; padding-bottom: 10px;}
.tabcontenttext {style="overflow: auto; height: 15px; width: 100%; padding-right: 19px;}

最佳答案

在 CSS 部分 .content 中,将 background-color: rgba(0,0,0,.6); 替换为 background-color: #282828;

设置为 0.6 的背景透明度会显示位于显示层下的内容。


新答案

.content 部分中,将 color: #fff; 替换为 color: transparent;

[type=radio]:checked ~ label ~ .content 部分添加 color: #fff;;在同一部分之后添加以下代码:

.content * {
visibility: hidden;
}

[type=radio]:checked ~ label ~ .content * {
visibility: visible;
}

此代码使底层的文本颜色透明(=不可见!)并隐藏其中的所有元素。

关于html - CSS 选项卡式 Div 不透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20727980/

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