css+div实现彩色碎纸屑粒子喷射动画效果代码
代码语言:html
所属分类:粒子
代码描述:css+div实现彩色碎纸屑粒子喷射动画效果代码
代码标签: css div 彩色 碎 纸屑 粒子 喷射 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
height: 100dvh;
display: grid;
place-items: center;
overflow: hidden;
background: #fdf5d4;
}
.container {
position: relative;
margin-bottom: 10dvh;
width: 100px;
height: 100px;
}
.confetti {
--random: 0.5;
--random-sine: calc((var(--random) - 0.5) * 2);
position: absolute;
top: 0;
left: 50%;
width: calc(60px + (var(--p) * 200px) + calc(var(--random) * 10%));
height: calc((var(--random) * 120px) + 170px);
border-radius: 40% 90% 0 0;
pointer-events: none;
--color: calc(var(--random) * 1turn) 85% 60%;
}
.container:hover .confetti {
border: solid 1px hsla(var(--color)/40%);
border-bottom: none;
border-left: none;
}
.confetti:nth-child(even) {
transform: scale(-1, 1);
left: auto;
right: 50%;
}
.confetti::before {
content: "";
display: block;
width: 12px;
height: 6px;
background-color: hsl(var(--color));
animation: confetti 2s cubic-bezier(0.5, 0, 0.5, 1) both, confetti-opacity 2s cubic-bezier(0.5, 0, 0.5, 1) both;
animation-duration: calc(1.4s + (var(--random) * 0.5s));
a.........完整代码请登录后点击上方下载按钮下载查看
网友评论0