How to set opacity to the background color of a di

2020-03-01 03:32发布

I have this class

.box { background-color:#fff; border:3px solid #eee; }

My question is how can I set an opacity to the white background only so that it will kinda mix with my background?

Thank you.

5条回答
时光不老,我们不散
2楼-- · 2020-03-01 03:36

I think rgba is the quickest and easiest!

background: rgba(225, 225, 225, .8)

查看更多
男人必须洒脱
3楼-- · 2020-03-01 03:36

I think this covers just about all of the browsers. I have used it successfully in the past.

#div {
    filter: alpha(opacity=50); /* internet explorer */
    -khtml-opacity: 0.5;      /* khtml, old safari */
    -moz-opacity: 0.5;       /* mozilla, netscape */
    opacity: 0.5;           /* fx, safari, opera */
}
查看更多
兄弟一词,经得起流年.
4楼-- · 2020-03-01 03:39

You can use CSS3 RGBA in this way:

rgba(255, 0, 0, 0.7);

0.7 means 70% opacity.

查看更多
萌系小妹纸
5楼-- · 2020-03-01 03:44

I would say that the easiest way is to use transparent background image.

http://jsfiddle.net/m48nH/

background: url("http://musescore.org/sites/musescore.org/files/blue-translucent.png") repeat top left;
查看更多
欢心
6楼-- · 2020-03-01 03:54

CSS 3 introduces rgba colour, and you can combine it with graphics for a backwards compatible solution.

查看更多
登录 后发表回答