这种效果可以通过纯CSS实现吗?
<!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>
.box {
margin-top: 200px;
margin-left: 300px;
position: relative;
}
.long {
height: 10px;
width: 200px;
border-radius: 5px;
background-color: rgba(0, 255, 255, 0.5);
}
.short {
height: 10px;
border-radius: 5px;
background-color: rgba(0, 255, 255, 0.5);
width: 50px;
position: absolute;
}
.short1,
.short4 {
width: 10px;
height: 50px;
}
.short1 {
top: 1px;
left: -4px;
transform: rotate(10deg);
}
.short4 {
left: 193px;
top: 1px;
transform: rotate(-10deg);
}
.short2 {
transform: rotate(-54deg);
top: 24px;
left: -17px;
width: 52px;
}
.short3 {
transform: rotate(54deg);
top: 24px;
left: 163px;
width: 52px;
}
</style>
</head>
<body>
<div class="box">
<div class="long"></div>
<div class="short1 short"></div>
<div class="short2 short"></div>
<div class="short3 short"></div>
<div class="short4 short"></div>
</div>
</body>
</html>
具体细节可以具体修改修改
<!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">
<style>
.container {
margin: 0 auto;
width: 300px;
height: 50px;
background-color: aqua;
clip-path: polygon(0 0, 100% 0, 100% 100%, 95% 30%, 5% 30%, 0 100%);
}
</style>
</head>
<body>
<div class="container"></div>
</body>
</html>
效果:
6 回答3.5k 阅读✓ 已解决
5 回答6.4k 阅读✓ 已解决
3 回答1.4k 阅读✓ 已解决
2 回答2.5k 阅读✓ 已解决
2 回答1.7k 阅读✓ 已解决
3 回答1.3k 阅读✓ 已解决
3 回答1.5k 阅读
看起来就是几个圆角矩形,旋转拼接而成,那么很容易实现,自己多试试就行了。
可能用到的 css 属性:
border-radius
width
height
transform: rotate()
transform-origin
position: absolute