html代码:
<div class="g-scroll" id="g-scroll"></div>
<div class="g-wrapper">
<div class="g-mask"></div>
<div class="g-inner">
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="g-item">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
</div>
</div>
css3代码:
@property --phase {
syntax: '';
inherits: false;
initial-value: 15px;
}
html, body {
width: 100%;
height: 100%;
display: flex;
}
.g-scroll {
width: 100%;
height: 1000vh;
position: relative;
}
.g-wrapper {
position: fixed;
top: -20%;
width: 100vw;
height: 100vh;
perspective: 200px;
transform-style: preserve-3d;
}
.g-mask {
position: fixed;
width: 100vw;
height: 120vh;
backdrop-filter: blur(5px);
transform: translateZ(0);
}
.g-inner {
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 10px;
transform-style: preserve-3d;
transform: translateY(calc(-50% + 100px)) translateZ(var(--phase)) rotateX(90deg);
transform-origin: bottom center;
animation-name: move;
animation-duration: 1s;
animation-timeline: box-move;
}
@scroll-timeline box-move {
source: selector("#g-scroll");
orientation: "vertical";
}
.g-item {
width: 300px;
height: 200px;
padding: 8px;
box-sizing: border-box;
color: #fff;
background: #000;
transform: rotateX(-90deg);
}
@keyframes move {
0% {
--phase: 0;
}
100% {
--phase: calc(100vh + 100px);
}
}
以上是编程学习网小编为您介绍的“css3利用视差实现做一个酷炫交互动效”的全面内容,想了解更多关于 前端知识 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:css3利用视差实现做一个酷炫交互动效
基础教程推荐
猜你喜欢
- JavaScript鼠标特效大全 2023-12-02
- IE、FF、Chrome浏览器中的JS差异介绍 2024-01-21
- Mac苹果电脑系统下如何彻底卸载node 2023-08-29
- 用CSS动态控制文本属性 2022-10-16
- Ajax 实现加载进度条 2023-01-26
- JavaScript实现网页带动画返回顶部的方法详解 2022-10-22
- el-form清除rules校验 2024-12-09
- 微信小程序自定义菜单导航实现楼梯效果 2023-08-12
- CSS使用自定义光标样式的实现_遁地龙卷风 2024-01-24
- js判断当前页面用什么浏览器打开的方法 2024-02-10