js实现多彩运动路径动画效果代码
代码语言:html
所属分类:动画
代码描述:js实现多彩运动路径动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
/* Best viewed in Chrome with Fullpage mode :) */
@import "https://fonts.googleapis.com/css2?family=Montserrat:wght@600&display=swap";
.particles{
--glow-layer: 0 0 0 0 rgba(0, 0, 0, 0);
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity: 0.85;
}
.particle{
--shadow-opacity: 0.06;
--depth-opacity: 0.2;
position: absolute;
left: 0;
top: 0;
opacity: 1;
box-sizing: border-box;
box-shadow:
var(--glow-layer),
1.5015vmin 1.5015vmin 1.5015vmin 0 rgba(0, 0, 0, var(--shadow-opacity)),
inset 1.5015vmin 1.5015vmin 1.5015vmin 0 rgba(255, 255, 255, var(--depth-opacity)),
inset -1.5015vmin -1.5015vmin 1.5015vmin 0 rgba(0, 0, 0, var(--depth-opacity));
transform: translate(0, 0) scale(0) rotate(0);
animation: trail linear 0.7s var(--i, 0s) forwards;
will-change: transform, opacity;
}
@keyframes trail{
10%{
transform: translate(0, 0) scale(1) rotate(0);
}
60%{
opacity: 1;
}
100%{
transform: translate(var(--shiftX, 0), var(--shiftY, 0)) scale(0) rotate(360deg);
opacity: 0;
}
}
.controls{
position: fixed;
right: 0;
top: 0;
display: inline-block;
box-sizing: border-box;
padding: 2vmin;
text-align: right;
font-family: 'Montserrat', sans-serif;
font-size: max(0.8em, 2.5vmin);
}
input{
position: relative;
left: 0;
top: 0;
opacity: 0;
margin: 0 -7px; /* a typical Windows checkbox is 14x14 in size */
}
input:checked + label{
color: var(--accent);
}
input:checked + label::before{
transform: translateY(30%) scaleX(1);
transform-origin: left top;
}
input:focus-visible + label{
outline: 2px solid var(--accent);
outline-offset: 4px;
}
label{
position: relative;
margin: 0 0.6em 1em 0;
font-weight: 600;
cursor: pointer;
transition: color ease 400ms;
color: var(--text-secondary);
display: inline-block;
}
label::before{
content: "";
position: absolute;
left: 0;
bottom: 0;
transform: translateY(30%) scaleX(0);
width: 100%;
height: 0.72em;
background-color: currentColor;
z-index: -1;
transform-origin: right top;
transition: transform ease 400ms;
opacity: 0.4;
}
label:hover{
color: var(--text);
}
.hint{
position: absolute;
right: 5vmin;
bottom: 0;
transform: translate(0%, 100%);
width: max(6.4em, 20vmin);
min-width: 6.4em;
max-width: 20vmin;
pointer-events: none;
opacity: 0.8;
overflow: visible;
}
.hint-text{
color: var(--accent);
fill: currentColor;
}
.special-arrow{
stroke: currentColor;
}
body[data-hint-shown='yes'] .hint{
animation: hide ease 0.3s 0.7s forwards;
}
@keyframes hide{
to{
opacity: 0;
}
}
/* to make things look pretty */
html, body{
position: relative;
inset: 0;
width: 100%;
min-height: 100vh;
padding: 0;
margin: 0;
display: block;
overflow: hidden;
}
html{
background-image: radial-gradient(circle at 50%, #fff, #f9f4fa);
background-size: 100% 100%;
background-attachment: fixed;
}
body{
background-color: transparent;
--accent: #245ef2;
--accent-alpha: #245ef2bb;
--text: #000;
--text-secondary: #00000093;
}
body::before{
content: "";
width: 100%;
height: 100%;
position: fixed;
left: 0;
top: 0;
background-image: radial-gradient(circle at 50%, #151515, #000);
background-size: 100% 100%;
background-attachment: fixed;
opacity: 0;
transition: opacity ease 300ms;
will-change: opacity;
}
/* I'm not sure but Firefox resolves to a lighter gradient */
@supports (-moz-appearance: none){
body::before{
background-image: radial-gradient(circle at 50%, #111, #000);
}
}
body.glow{
--accent: #f224da;
--accent-alpha: #f224dabb;
--text: #fff;
--text-secondary: #ffffff93;
}
body.glow::before{
opacity: 1;
}
body.glow .particles{
--glow-layer: 0 0 15.015vmin 1.5015vmin currentColor;
opacity: 1;
filter: contrast(1.5);
}
::selection{
color: #fff;
background-color: var(--accent-alpha);
}
/* Made with Coffee, Care, and Curiosity by @ShadowShahriar */
</style>
</head>
<body>
<!-- Excited with this project o(^▽^)o -->
<div class="particles"></div>
<div class="shadows"></div>
<div class="controls">
<input id="toggle-rainbow" type="checkbox" data-changes="rainbow"/>
<label for="toggle-rainbow">Rainbow</label>
<input id="toggle-circles" type="checkbox" data-changes="circles"/>
<label for="toggle-circles">Circles</label>
<.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0