如何在css中使身体背景图像透明?

4 css css3

根据我的知识,没有css属性可以使背景图像透明,我一次又一次地尝试,但我仍然远离解决方案,这是我的方法:

body {
    background-image: url("PPI01.jpg");
    background-attachment: fixed;
    background-position: bottom;
    filter: opacity(opacity: 30%);
    z-index: -1;
    background-repeat: no-repeat;
}
Run Code Online (Sandbox Code Playgroud)

我寻找其他如此问题并找到类似的东西,但问题仍然存在.

sir*_*dn4 8

也许这可以帮到你.你必须把你的背景放在body :: after之后

<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style type="text/css">
body {
  width: 1200px;
  height: 1200px;
  display: block;
  position: relative;
  margin: 0 auto;
  z-index: 0;
}

body::after {
  background: url(http://kingofwallpapers.com/background-image-laptop/background-image-laptop-018.jpg);
  content: "";
  opacity: 0.9;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  z-index: -1;   
}

div {
  font-size: 36px;
  color: white;
}

	</style>
</head>
<body>
 <div>
   The text will not affected by the body
 </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)