透明的背景,不透明的元素 [英] Transparent background, opaque elements

查看:128
本文介绍了透明的背景,不透明的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 body 和主要 div 的半透明背景上有图像背景,以便图像可以通过它看到,但阴影。然而,最简单的方法是:

$ body $ {
background-image:...
}

#main {
background-color:#999;
opacity:0.9
}

也会使 #main 也是不透明的,例如任何包含 img



你如何做我所描述的?



谢谢 rgba帮助你,但它不被所有浏览器支持



用法:

  rgba(a,b,c,d),其中a =红色(0-255); b =绿色(0-255); c =蓝色(0-255),d = alpha不透明度(0-1)

想要50%的红色背景,您应该使用


background:rgba(255,0,0,0.5);



I want to have an image background on body and a semitransparent background on main div, so that the image can be seen through it, but shaded. However, the easiest

body {
  background-image: ...
}

#main {
  background-color: #999;
  opacity: 0.9
}

will also make everything within #main to be opaque as well, such as any contained img.

How do you do what I describe?

Thanks

解决方案

rgba helps you, but it is not supported by all browsers

usage:

rgba(a,b,c,d), where a = red(0-255); b = green(0-255); c = blue(0-255), d = alpha opacity(0-1)

so if you want a 50% red background, you should use

background: rgba(255,0,0,0.5);

这篇关于透明的背景,不透明的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆