- 效果
- 测试代码
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="x">
<div class="a item"></div>
<div class="b item"></div>
<div class="c item"></div>
</div>
</body>
<style>
.x{
width: 500px;
height: 500px;
/*background-color: red;*/
margin: 200px;
border:1px solid black;
position: relative;
}
.item{
width: 100px;
height: 100px;
opacity: 0.33333;
}
.a{
background-color: red;
}
.b{
background-color: green;
margin-top:-20px;
}
.c{
position: absolute;
left: 80px;
top:0;
background-color: blue;
}
</style>
</html>
首先,你这样的测试是不对的,三个元素叠加不是色彩叠加,是覆盖,就好比三种颜色的盒子放一起颜色会混合吗?其次,光学三原色叠加不是黑色是白色,黑色是颜料叠加的结果。想看真正的混合结果参考这个:
https://developer.mozilla.org...