css实现手机移动设备图片堆叠拖拽切换效果代码
代码语言:html
所属分类:拖放
代码描述:css实现手机移动设备图片堆叠拖拽切换效果代码,电脑端不支持拖拽。
代码标签: css 手机 移动 设备 图片 堆叠 拖拽 切换
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
@charset "UTF-8";
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;
--dim-card-width: 300px;
--dim-card-height: 400px;
--dim-card-border-radius: 16px;
--box-shadow-card: 0 1px 12px rgba(0, 0, 0, 0.4);
}
::-webkit-scrollbar {
display: none;
}
* {
box-sizing: border-box;
}
body,
html {
margin: 0;
padding: 0;
}
body {
display: flex;
align-items: center;
justify-content: center;
background-color: #ddd;
height: 100vh;
min-height: 800px;
timeline-scope: --scroll-timeline;
animation: theme-bg linear forwards;
animation-timeline: --scroll-timeline;
}
main {
width: 800px;
height: 600px;
perspective: 1000px;
transform-style: preserve-3d;
}
.scroller {
width: 100%;
height: 100%;
overflow: auto;
white-space: nowrap;
display: flex;
scroll-snap-type: x mandatory;
scroll-timeline: --scroll-timeline;
scroll-timeline-axis: x;
}
.scroll-item {
flex: 0 0 100%;
height: 100%;
scroll-snap-align: start;
}
[data-debug=true] .scroll-item {
outline: 1px dashed magenta;
}
.card-stack {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
transform-style: preserve-3d;
pointer-events: none;
}
.card {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
width: var(--dim-card-width);
height: var(--dim-card-height);
border-radius: var(--dim-card-border-radius);
display: flex;
align-items: center;
justify-content: center;
transform-style: preserve-3d;
overflow: hidden;
background-color: rgba(255, 255, 255, 0.8);
box-shadow: var(--box-shadow-card);
}
.card img {
position: absolute;
object-fit: cover;
width: 100%;
z-index: 1;
height: 100%;
}
.card::before {
position: absolute;
top: -4px;
bottom: -4px;
right: -4px;
left: -4px;
content: "";
}
.card:nth-child(1) {
animation: animate1-inactive linear forwards;
animation-timeline: --scroll-timeline;
}
[data-active-index="0"] .card:nth-child(1) {
animation: animate1-active linear forwards;
animation-timeline: --scroll-timeline;
}
.card:nth-child(1) img {
animation: animate-card-image-1 linear forwards;
animation-timeline: --scroll-timeline;
}
[data-active-index="0"] .card-stack {
animation: card-stack-1 linear forwards;
animation-timeline: --scroll-timeline;
}
.card:nth-child(1)::before {
animation: card-bg linear forwards;
animation-timeline: --scroll-timeline;
}
@keyframes animate1-active {
0% {
transform: translateX(0) rotateY(0) rotateZ(0) rotateX(0) translateZ(0);
}
12.5% {
transform: translateX(-116%) rotateY(-24deg) rotateZ(0) rotateX(2deg) translateZ(-156px);
}
25% {
transform: translateX(-11%) rotateY(0) rotateZ(-6deg) rotateX(0) translateZ(-160px);
}
50% {
transform: translateX(-19%) rotateY(0) rotateZ(-8deg) rotateX(0) translateZ(-180px);
}
75% {
transform: translateX(-27%) rotateY(0) rotateZ(-10deg) rotateX(0) translateZ(-200px);
}
100% {
transform: translateX(-35%) rotateY(0) rotateZ(-12deg) rotateX(0) translateZ(-220px);
}
}
@keyf.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0