CSS:在不设置rgba的情况下设置背景不透明度 [英] CSS: Setting background opacity without rgba
本文介绍了CSS:在不设置rgba的情况下设置背景不透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在下面的代码中,我只想为li
的背景色(而不是文本)设置不透明度.但是,重要的是不要将rgba
用作背景.
In the following code, I want to set the opacity only for the background color of the li
(not the text). However, it is important NOT to use the rgba
for the background.
我正在尝试跟踪,但是它也为链接文本设置了不透明度.
I'm trying following, but it sets the opacity for the link text as well.
HTML:
<ul>
<li><a href="#">Hello World</a></li>
</ul>
CSS:
body{
background: red;
}
ul{
margin: 100px;
}
li{
padding: 10px;
background: #000000;
opacity: 0.1;
}
a{
color: #fff;
font-weight: 700;
opacity: 1;
}
JSFiddle: http://jsfiddle.net/2uJhL/
推荐答案
您可以将PNG或GIF图像设置为背景,即:
You can set a PNG or GIF image as background, i.e:
li {
background-image: url('path/to/your/image.png');
}
这篇关于CSS:在不设置rgba的情况下设置背景不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文