[英]How can I set the image opacity for body background
How can I set the image opacity for the image in the background of the body
tag 如何在
body
标签的背景中设置图像的图像不透明度
my html: 我的html:
<body background="http://ib1.keep4u.ru/b/070815/ef2714da63d5940bf5.jpg">
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
<div>test</div>
</body>
my css: 我的CSS:
body{
opacity: 0.1,
filter:alpha(opacity=10)
}
There is no CSS property background-opacity, but you can fake it by inserting a pseudo element with regular opacity the exact size of the element behind it. 没有CSS属性background-opacity,但是您可以通过插入一个伪元素来伪造它,该伪元素具有常规的opacity,且元素的确切大小与之完全相同。
it can be done like this 可以这样做
body::after {
content: "";
background: url(http://ib1.keep4u.ru/b/070815/ef2714da63d5940bf5.jpg);
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
z-index: -1;
}
Check it here http://jsfiddle.net/dyaa/k4dw5hyq/2/ 在这里检查http://jsfiddle.net/dyaa/k4dw5hyq/2/
Edit: no need for opacity and filter in the body tag anymore http://jsfiddle.net/dyaa/k4dw5hyq/3/ 编辑:不再需要不透明性,并且不需要在body标签中进行过滤http://jsfiddle.net/dyaa/k4dw5hyq/3/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.