示例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>opacity</title>
<style type="text/css">
div {
border-color: #000000;
border-width: 1px;
border-style: solid;
margin: 5px;
padding: 5px;
}
p {
background-color: #40e0d0;
padding: 5px;
}
</style>
</head>
<body>
<div style="opacity: 0.22;">
<p>
The opacity CSS property sets the opacity of an element. Opacity is the degree to which content behind an element is hidden, and is the opposite of transparency.
</p>
</div>
<div style="opacity: 1;">
<p>
opacity applies to the element as a whole, including its contents, even though the value is not inherited by child elements. Thus, the element and its children all have the same opacity relative to the element's background, even if they have different opacities relative to one another.
</p>
</div>
</body>
</html>
参考
Web technology for developers > CSS: Cascading Style Sheets > opacity