使用伪元素。
<!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>
</head>
<style>
.box {
width: 200px;
height: 100px;
background: red;
}
.box::before {
content: " ";
width: 5px;
height: 40px;
border-radius: 10px;
position: relative;
top: 25px;
display: block;
background: yellow;
}
</style>
<body>
<div class="box">
</div>
</body>
</html>
13 回答12.9k 阅读
8 回答2.7k 阅读
2 回答5.1k 阅读✓ 已解决
5 回答1.4k 阅读
9 回答1.7k 阅读✓ 已解决
5 回答1.3k 阅读
3 回答2.3k 阅读✓ 已解决
用渐变吧
下面是一个 demo
https://codepen.io/xboxyan/pe...