<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body{
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.box{
position: relative;
width: 300px;
height: 150px;
background: orange;
-webkit-mask:radial-gradient(circle at 20px 20px, transparent 20px, red 0) -20px -20px / 50% 100%,
radial-gradient(circle at 5px 5px, transparent 5px, red 0) -155px -5px / 100% 9%;
-webkit-mask-composite: source-in;
}
</style>
</head>
<body>
<div class="box"></div>
</body>
</html>
主要代码
-webkit-mask
-webkit-mask
的用法类似于background
-webkit-mask: color [position] / [size] [repeat]
background: color [position] / [size] [repeat]
radial-gradient
径向渐变
radial-gradient(形状 at 起始点位置, 颜色断点1, 颜色断点2) ...
-webkit-mask-composite: source-in;` 混合方式