使用 opacity属性,参数从0到1.0,完全透明是 0.0,完全不透明是 1.0,参数越小越透明
.item{width:200px;height: 200px;display: flex;justify-content: center;align-items: center;color:#333;border-radius: 50%;opacity: 0.5;background:#DC143C; }
但是这样的写法会使得其中的文字也变得透明:
12 使用rgba方式, 推荐十六进制颜色转rgba在线工具,获取到前三位数据之后,第四位就是透明度了,和上述opacity原理类似,但是不会改变其中的文字透明度:
.item{width:200px;height: 200px;display: flex;justify-content: center;align-items: center;color:yellow;border-radius: 50%;background:rgba(220,20,60,0.5); }