feat: 跨境电商3套模板添加3D动态光影效果
- shop: 红色经典风格 - 鼠标红色光斑+卡片8度3D倾斜+玻璃高光+Hero视差 - shop2: 暗黑霓虹风格 - 霓虹紫青光斑+卡片10度3D倾斜+霓虹高光+12个浮动粒子 - shop3: 北欧极简风格 - 柔和暖色光斑+卡片6度3D倾斜+柔和高光+入场动画
This commit is contained in:
109
web/dist/shop3/index.html
vendored
109
web/dist/shop3/index.html
vendored
@@ -883,6 +883,71 @@ input { font-family: inherit; outline: none; }
|
||||
.toolbar { flex-direction: column; align-items: flex-start; }
|
||||
.modal-meta { grid-template-columns: 1fr 1fr 1fr; }
|
||||
}
|
||||
|
||||
/* ========== 3D 动效 & 鼠标光影(北欧极简 · 克制优雅)========== */
|
||||
|
||||
/* 全局鼠标跟随柔光斑(灰粉 → 灰绿 → 透明,multiply 柔和叠加)*/
|
||||
.cursor-glow{
|
||||
position:fixed;
|
||||
top:0; left:0;
|
||||
width:500px; height:500px;
|
||||
border-radius:50%;
|
||||
background:radial-gradient(circle, rgba(212,165,165,0.10) 0%, rgba(168,197,160,0.06) 40%, transparent 70%);
|
||||
pointer-events:none;
|
||||
z-index:150; /* 高于导航栏(100),低于所有弹窗(180+) */
|
||||
transform:translate(-50%,-50%);
|
||||
mix-blend-mode:multiply;
|
||||
filter:blur(10px);
|
||||
will-change:transform;
|
||||
}
|
||||
|
||||
/* 3D 透视容器 */
|
||||
.products-grid{ perspective:1000px; }
|
||||
.featured-grid{ perspective:1000px; }
|
||||
|
||||
/* 卡片 3D 倾斜基础(preserve-3d + 柔和过渡)*/
|
||||
.product-card{
|
||||
position:relative;
|
||||
transform-style:preserve-3d;
|
||||
transition:transform .3s var(--ease), box-shadow .3s var(--ease);
|
||||
}
|
||||
.product-card .product-img{ transform:translateZ(20px); }
|
||||
.product-card .product-info{ transform:translateZ(12px); }
|
||||
|
||||
/* 卡片表面柔和高光反射(::after 跟随鼠标位置,浮于卡片最前层)*/
|
||||
.product-card::after{
|
||||
content:'';
|
||||
position:absolute;
|
||||
inset:0;
|
||||
border-radius:inherit;
|
||||
background:radial-gradient(circle at var(--mx,50%) var(--my,50%), rgba(255,255,255,0.40) 0%, transparent 50%);
|
||||
opacity:0;
|
||||
transition:opacity .4s var(--ease);
|
||||
pointer-events:none;
|
||||
z-index:2;
|
||||
transform:translateZ(30px);
|
||||
}
|
||||
.product-card:hover::after{ opacity:1; }
|
||||
|
||||
/* 页面入场动画(各区块淡入上滑,错开延迟)*/
|
||||
@keyframes fadeInUp{ from{ opacity:0; transform:translateY(30px); } to{ opacity:1; transform:translateY(0); } }
|
||||
.top-strip{ animation:fadeInUp .8s var(--ease) both; animation-delay:0s; }
|
||||
.navbar{ animation:fadeInUp .8s var(--ease) both; animation-delay:.10s; }
|
||||
.hero{ animation:fadeInUp .8s var(--ease) both; animation-delay:.20s; }
|
||||
.values{ animation:fadeInUp .8s var(--ease) both; animation-delay:.30s; }
|
||||
.category-bar{ animation:fadeInUp .8s var(--ease) both; animation-delay:.40s; }
|
||||
.shop{ animation:fadeInUp .8s var(--ease) both; animation-delay:.50s; }
|
||||
.featured{ animation:fadeInUp .8s var(--ease) both; animation-delay:.60s; }
|
||||
.footer{ animation:fadeInUp .8s var(--ease) both; animation-delay:.70s; }
|
||||
|
||||
/* 移动端关闭光斑 / 尊重「减弱动效」偏好 */
|
||||
@media (max-width: 860px){ .cursor-glow{ display:none; } }
|
||||
@media (prefers-reduced-motion: reduce){
|
||||
.cursor-glow{ display:none; }
|
||||
.top-strip,.navbar,.hero,.values,.category-bar,.shop,.featured,.footer{ animation:none; }
|
||||
.product-card{ transition:none; }
|
||||
.product-card::after{ transition:none; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -1473,6 +1538,50 @@ async function init() {
|
||||
updateCartUI();
|
||||
}
|
||||
init();
|
||||
|
||||
// ========== 3D 动效 & 鼠标光影(北欧极简 · 克制优雅)==========
|
||||
(function(){
|
||||
var reduceMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
if (reduceMotion) return;
|
||||
|
||||
/* —— 全局鼠标跟随柔光斑(轻柔拖尾,北欧式优雅)—— */
|
||||
var cursorGlow = document.createElement('div');
|
||||
cursorGlow.className = 'cursor-glow';
|
||||
document.body.appendChild(cursorGlow);
|
||||
var gx = window.innerWidth / 2, gy = window.innerHeight / 2;
|
||||
var tx = gx, ty = gy;
|
||||
cursorGlow.style.transform = 'translate3d(' + gx + 'px,' + gy + 'px,0) translate(-50%,-50%)';
|
||||
document.addEventListener('mousemove', function(e){ tx = e.clientX; ty = e.clientY; });
|
||||
(function loop(){
|
||||
gx += (tx - gx) * 0.16;
|
||||
gy += (ty - gy) * 0.16;
|
||||
cursorGlow.style.transform = 'translate3d(' + gx.toFixed(2) + 'px,' + gy.toFixed(2) + 'px,0) translate(-50%,-50%)';
|
||||
requestAnimationFrame(loop);
|
||||
})();
|
||||
|
||||
/* —— 产品卡片 3D 倾斜(最大 6°,柔和流畅;事件委托兼容动态渲染)—— */
|
||||
var activeCard = null;
|
||||
document.addEventListener('mousemove', function(e){
|
||||
var card = (e.target && e.target.closest) ? e.target.closest('.product-card') : null;
|
||||
if (card !== activeCard){
|
||||
if (activeCard){ activeCard.style.transform = ''; }
|
||||
activeCard = card;
|
||||
}
|
||||
if (!card) return;
|
||||
var rect = card.getBoundingClientRect();
|
||||
var cx = rect.left + rect.width / 2;
|
||||
var cy = rect.top + rect.height / 2;
|
||||
var rx = ((e.clientY - cy) / rect.height) * -6; // 北欧克制:最大 6°
|
||||
var ry = ((e.clientX - cx) / rect.width) * 6;
|
||||
card.style.transform = 'perspective(1000px) rotateX(' + rx.toFixed(2) + 'deg) rotateY(' + ry.toFixed(2) + 'deg) translateY(-6px)';
|
||||
card.style.setProperty('--mx', ((e.clientX - rect.left) / rect.width * 100).toFixed(1) + '%');
|
||||
card.style.setProperty('--my', ((e.clientY - rect.top) / rect.height * 100).toFixed(1) + '%');
|
||||
});
|
||||
/* 鼠标移出文档时复位倾斜 */
|
||||
document.addEventListener('mouseleave', function(){
|
||||
if (activeCard){ activeCard.style.transform = ''; activeCard = null; }
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user