gpt4 book ai didi

javascript - 不透明元素上的非不透明元素

转载 作者:太空宇宙 更新时间:2023-11-03 23:47:41 24 4
gpt4 key购买 nike

我试图在一些 div 中设计一个按钮。div 的不透明度为 0.8,但我不希望它的按钮(子按钮)具有其 super (祖先)div 不透明度。如何实现?我试过这个html:

 <div class="divBox">
<span class="title"> Some title </span>
<hr>

<div>
<span> Some Content </span>
</div>

<div class="divButton">
<a class="myButton"> Button </a>
</div>
</div>

CSS:

.divBox{
background-color: #ffffff;
-webkit-border-radius: 10px;
border-radius: 10px;
padding: 2%;
}

.divButton{
text-align: left;
padding-bottom: 1%;
padding-top: 3%;
}

.myButton{
background-color: #295b9f;
color: white;
padding: .5em .5em;
cursor: pointer;
border: aliceblue;
-webkit-border-radius: 20px;
border-radius: 3px;
margin-top: 2%;
opacity: 1;
}

谢谢你的帮助

最佳答案

对父项和子项都使用rgba(r, g, b, a) background-color 而不是opacitya 指的是 alpha 值或不透明度。

.parent {
background-color: rgba(255,0,0, 0.8); /* change r,g,b as needed */
}

.parent .child {
background-color: rgba(255,0,0, 1); /* change r,g,b as needed */
}

关于javascript - 不透明元素上的非不透明元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21157456/

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