透明度

CSS3引入了opacity属性,opacity属性允许你指定元素及其子元素的透明度。该属性值是一个介于0.0~1.0之间的数字(以此推算,0.5表示50%的透明度,0.15表示15%的透明度)。

<!DOCTYPE html>
<html>
	<head>
		<title>Opacity</title>
		<style type="text/css">
			div {
				 100px;
				height: 100px;
				margin: 40px;
				display: inline-block;
				background-color: #ee3e80;}
			p {
				 100px;
				height: 100px;
				position: relative;
				top: 20px;
				left: 20px;
				margin: 20px;}
			p.one {
				background-color: rgb(0,0,0);
				opacity: 0.5;}
			p.two {
				background-color: rgb(0,0,0);
				background-color: rgba(0,0,0,0.5);}
		</style>
	</head>
	<body>
		<div><p class="one"></p></div>
		<div><p class="two"></p></div>
	</body>
</html>
原文地址:https://www.cnblogs.com/q2546/p/9417844.html