編碼的世界 / 優質文選 / 生涯

css實現兩邊有缺口的卡券效果


2021年11月22日
-   

自己項目用到優惠券的樣式,特拿來分享。主要用到了css的position: absolute屬性。 效果如下圖: 廢話不多說,直接上代碼
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>驗證券樣式</title>
<style>
body{
background-color: #E2DFDF;
}
.div{
position: relative;
width: 200px;
height: 100px;
margin:100px auto;
background-color: #fff;
}
.yuan1{
position: absolute;
width: 20px;
height: 20px;
border-radius: 20px;
background-color: #E2DFDF;
left: -10px;
top:40px;
}
.yuan2{
position: absolute;
width: 20px;
height: 20px;
border-radius: 20px;
background-color: #E2DFDF;
right: -10px;
top:40px;
}
</style>
</head>
<body>
<div class="div">
<div class="yuan1"></div>
<div class="yuan2"></div>
</div>
</body>
</html>

熱門文章