是否可以设置背景图像的不透明度而不影响子元素的不透明度?
页脚中的所有链接都需要自定义项目符号(背景图像),并且自定义项目符号的不透明度应为 50%。
#footer ul li {
background: url(/images/arrow.png) no-repeat 0 50%;
}
我尝试将列表项的不透明度设置为 50%,但链接文本的不透明度也是 50% - 并且似乎没有办法重置子元素的不透明度:
#footer ul li {
background: url(/images/arrow.png) no-repeat 0 50%;
/* will also set the opacity of the link text */
opacity: 0.5;
}
我也尝试过使用 rgba,但这对背景图像没有任何影响:
#footer ul li {
/* rgba doesn't apply to the background image */
background: rgba(255, 255, 255, 0.5) url(/images/arrow.png) no-repeat 0 50%;
}
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号