gsap+css实现炫酷图片鼠标交互重复拖拽阴影效果代码

代码语言:html

所属分类:其他

代码描述:gsap+css实现炫酷图片鼠标交互重复拖拽阴影效果代码,多种拖影和旋转形状特效。

代码标签: gsap css 炫酷 图片 鼠标 交互 重复 拖拽 阴影

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
  
  
  
<style>
@import url("https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;700&display=swap");

body {
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  margin: 0;
  font-family: "Arial", sans-serif;
  gap: 40px;
  padding: 20px;
  overflow: hidden;
}

.main-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
}

h1 {
  position: absolute;
  top: -25px;
  margin: 0 auto;
  color: white;
  font-size: 12px;
  font-weight: 900;
}
h1 span {
  position: relative;
  font-size: 8px;
  top: -4px;
}

.image {
  width: 400px;
  height: 500px;
  background-size: cover;
  background-position: center;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
  cursor: grab;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.image.dragging {
  cursor: grabbing;
}

.image.rotation-active {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.image__element {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: clip-path 0.3s ease;
}

.image__element.base-layer {
  z-index: 1;
}

.image__element:not(.base-layer) {
  z-index: 2;
}

.layer-outline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.layer-outline.active {
  opacity: 0.5;
}

.layer-outline svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}
.layer-shadow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 14;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.layer-shadow.active {
  opacity: 1;
}

.layer-shadow svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: blur(4px);
}

.image__element.rectangle {
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
}

.image__element.triangle {
  clip-path: polygon(50% 5%, 10% 95%, 90% 95%);
}

.image__element.chevron {
  clip-path: polygon(75% 0%, 100% 50%, 75% 100%, 0% 100%, 25% 50%, 0% 0%);
}

.image__element.oval {
  clip-path: ellipse(45% 35% at 50% 50%);
}

.controls {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  gap: 30px;
  align-items: center;
}

.shape-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.shape-btn {
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 12px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shape-btn:hover {
  color: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

.shape-btn.active {
  background: #ff9a9c;
  color: #ffffff;
  border-radius: 2px;
}

.effect-controls {
  display: flex;
  gap: 15px;
  align-items: center;
}

.effect-controls span {
  color: white;
  font-family: "Roboto Mono", monospace;
  font-size: 12px;
  font-weight: 500;
}

.effect-btn {
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 25px;
  color: white;
  font-family: "Roboto Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.effect-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.effect-btn.active {
  background: #ff9a9c;
  border-color: #ff9a9c;
  box-shadow: 0 0 15px rgba(255, 154, 156, 0.3);
}

.cursor-drag {
  position: fixed;
  top: 0;
  left: 0;
  font-family: "Roboto Mono", monospace;
  font-size: 14px;
  font-weight: 400;
  color: white;
  padding: 8px 12px;
  pointer-events: none;
  z-index: 1000;
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-10px);
  overflow: hidden;
  height: 20px;
}

.drag-text {
  display: block;.........完整代码请登录后点击上方下载按钮下载查看

网友评论0