<分区>
<分区>
我正在尝试制作一个带有圆 Angular 和一点透明度的白色按钮。文字不应该是透明的。我尝试使用 opacity: initial
对于 <p>
风格,但它似乎不起作用。查看我的代码片段以更好地理解。
body {
background-color: #264D38;
}
.button {
display: inline-block;
width: 150px;
border-radius: 2px;
margin-top: 20px;
margin-bottom: 20px;
background-color: #898989;
opacity: 0.4;
filter: alpha(opacity=40); /* Para IE8 e anteriores */
}
span.button > p {
opacity: initial;
padding: 10px;
color: #ffffff;
font-weight: bold;
text-align: center;
}
.button:hover {
background-color: #000000;
}
<body>
<a href="#"><span class="button"><p>BUY NOW</p></span></a>
</body>
最佳答案
你可以使用 RGBA背景颜色的值而不是使用不透明度。
示例
.button {
display: inline-block;
width: 150px;
border-radius: 2px;
margin-top: 20px;
margin-bottom: 20px;
background-color: rgba(137,137,137,.4);
}
关于html - 如何使 <p> 不继承 <span> 不透明样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36500627/