[CSS] Scroll animation: scroll-snap
Video: https://www.youtube.com/watch?v=zqjKE_zcWzE&list=WL&index=68&t=14s
code: https://github.com/Alliemack77/scroll-animations-with-css-only
/* Custom props */
:root {
--transition-250-ease-in: 250ms ease-in;
}
/* Reset */
*::after,
*::before {
box-sizing: border-box;
}
img {
max-width: 100%;
display: block;
}
body {
background-color: #07072c;
margin: 0;
}
p {
margin: 0;
}
/* scroll container is the HTML element */
html {
scroll-snap-type: x mandatory;
cursor: url(./images/cursor.cur), pointer;
}
.gallery {
height: 95vh;
display: grid;
grid-auto-flow: column;
grid-auto-columns: 100vw;
}
section {
display: grid;
place-content: center;
scroll-snap-align: center;
}
.card {
width: 300px;
aspect-ratio: 9 / 16;
cursor: pointer;
position: relative;
perspective: 1000px;
transform-style: preserve-3d;
animation: swoosh linear;
animation-timeline: view(inline);
@media (prefers-reduced-motion: reduce) {
animation: none;
}
}
.card > * {
position: absolute;
border-radius: 20px;
}
.tardis {
box-shadow: 5px 5px 15px 5px rgb(1, 0, 7);
opacity: 1;
rotate: none;
transition: all var(--transition-250-ease-in);
}
.card.active .tardis {
opacity: .25;
rotate: x 30deg;
transform: translateY(-70px);
}
.doctor,
.title {
opacity: 0;
transition: all var(--transition-250-ease-in);
}
.card.active .doctor,
.card.active .title {
opacity: 1;
translate: 0 0 120px;
transform: translateY(-70px);
}
.title {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
font-size:1.75rem;
text-align: center;
color: white;
inset: 90% 0%;
}
@keyframes swoosh {
0% {
scale: .5;
rotate: 1 1 1 95deg;
}
50% {
scale: 1;
rotate: none;
}
100% {
scale: .5;
rotate: 1 1 1 -95deg;
}
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2020-07-01 [AWS] AWS Serverless Application Model (AWS SAM)
2020-07-01 [Functional Programming] Function modelling -- 10. Free Monads
2016-07-01 [RxJS] Drag and Drop example
2014-07-01 [Android] Content provider, ContentResolver