css实现滚动页面驱动svg路径动画效果代码
代码语言:html
所属分类:加载滚动
代码描述:css实现滚动页面驱动svg路径动画效果代码,使用css新属性animation-timeline实现。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@import url("https://fonts.googleapis.com/css2?family=Architects+Daughter&family=Roboto:wght@100;400&display=swap");
.path-cont {
position: fixed;
width: 20vw;
height: 100vh;
top: 0;
left: 0;
pointer-events: none;
color: #FBF7F490;
z-index: -10;
}
.svgpath {
width: 100%;
height: 100%;
position: absolute;
inset: 0;
}
.svgpath path {
stroke: #FBF7F430;
}
.obj {
position: absolute;
offset-path: polygon(51% 0%, 61% 7%, 69% 12%, 74% 18%, 72% 25%, 62% 29%, 45% 32%, 29% 32%, 13% 26%, 20% 19%, 37% 15%, 56% 15%, 68% 17%, 80% 24%, 82% 31%, 76% 37%, 67% 43%, 57% 49%, 44% 55%, 35% 60%, 26% 66%, 25% 70%, 30% 75%, 36% 81%, 46% 86%, 55% 91%, 65% 96%, 72% 99%);
position: absolute;
animation: followpath linear;
animation-timeline: scroll();
}
@keyframes followpath {
from {
offset-distance: 2%;
}
to {
offset-distance: 60%;
}
}
body {
background-color: #1f2020;
color: #FBF7F4;
font-family: Roboto, sans-serif;
font-weight: 100;
}
h1 {
font-family: "Architects Daughter", cursive;
font-size: clamp(2rem, 8vw + 1rem, 10rem);
line-height: 1;
margin: 0;
background-image: linear-gradient(#ff6090, #E23636);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
}
p {
line-height: 1.5;
}
.big-thing {
width: min(50ch, 100% - 2rem);
margin: 0 auto;
}
.obj {
--bg: white;
--brd: #ff6090;
width: 3vmin;
height: 1.5vmin;
border-top-right-radius: 30% 20%;
border-bottom-right-radius: 30% 20%;
border-top-left-radius: 30% 15%;
border-bottom-left-radius: 30% 15%;
border: 1px solid var(--brd);
border-width: 0.5vmin 2.5vmin 0.5vmin 0.8vmin;
box-shadow: 0 0 0 0.08em #000;
background-color: var(--bg);
}
.path-cont:before {
content: "0%";
position: absolute;
left: 40%;
}
.path-cont:after {
content: "100%";
position: absolute;
right: 0;
bottom: .........完整代码请登录后点击上方下载按钮下载查看
网友评论0