首页 > 其他分享 >精美卡片拖拽仿3D效果

精美卡片拖拽仿3D效果

时间:2023-02-19 10:32:04浏览次数:53  
标签:const linear 卡片 -- transform content styled 拖拽 3D


精美卡片拖拽仿3D效果_ci

3D效果 ​​https://micku7zu.github.io/vanilla-tilt.js/index.html​​​ 体验地址 ​​https://hongbin.xyz/home​

import { FC, ReactElement, useEffect } from "react";
import styled, { keyframes } from "styled-components";
import { randomColor } from "../BUI/DateTimePicker/utils";
import "../../constant/VanillaTilt";

interface IProps {}

const initialData: { title: string; content: string; desc?: string }[] = [
{ title: "极客精神", content: "好奇之心", desc: "改变之力" },
{ title: "开源精神", content: "开创", desc: "共享" },
{ title: "终身学习", content: "学无止境", desc: "不断探索" },
{ title: "团队精神", content: "相信自己", desc: "相信伙伴" },
];

const Quality: FC<IProps> = (): ReactElement => {
useEffect(() => {
VanillaTilt.init(document.querySelectorAll(".qualityCard"));
}, []);

return (
<Wrap>
{initialData.map((item, index) => (
<CardStyled
className="qualityCard"
style={{
// @ts-ignore
"--after-bgc": `${randomColor()}cc`,
// @ts-ignore
"--before-bgc": `${randomColor()}cc`,
// @ts-ignore
"--before-duration": `${5 + Math.floor(Math.random() * 10)}s`,
// @ts-ignore
"--after-duration": `${5 + Math.floor(Math.random() * 10)}s`,
}}
key={item.title}
>
<Index>0{index + 1}</Index>
<Title>{item.title}</Title>
<Content>
{item.content}
{item.desc ? (
<>
<br />
{item.desc}{" "}
</>
) : null}
</Content>
</CardStyled>
))}
</Wrap>
);
};

export default Quality;

const Content = styled.article`
color: #fffae5;
font-size: 1.5rem;
text-align: center;
font-weight: bold;
transition: opacity 0.2s linear, transform 0.3s linear,
text-shadow 0.3s linear;
opacity: 0;
transform: translateY(5rem);
`;

const Title = styled.p`
font-size: 2rem;
color: #777;
text-shadow: 1px 1px #ccc;
letter-spacing: 7px;
text-align: right;
font-weight: bolder;
margin-top: 6rem;
transition: all 0.3s linear;
`;

const Index = styled.strong`
font-size: 5rem;
color: #777;
position: absolute;
right: 0;
top: 0;
text-shadow: 2px 2px #ccc;
letter-spacing: 7px;
transition: all 0.3s linear;
`;

const downAnimate = keyframes`
0%{transform: translate(0px,0px) };
30%{transform: translate(0.9rem,0.9rem) };
60%{transform: translate(-0.9rem,-0.9rem) };
100%{transform: translate(0px,0px) };
`;

const CardStyled = styled.div`
width: 15rem;
height: 18rem;
border-radius: 1rem;
margin: 1rem 0;
position: relative;
font-family: fantasy;
transition: background 0.3s linear;
background: #96969644;
${props => props.theme.backdropFilter || props.theme.replaceBDFilter};
border-top: #999 2px solid;
border-left: #aaa 2px solid;
border-right: #999 2px solid;
border-bottom: #aaa 2px solid;
overflow: hidden;

::before {
content: "";
position: absolute;
width: 6rem;
height: 6rem;
z-index: -1;
border-radius: 6rem;
background-color: var(--before-bgc);
top: -2rem;
left: -2rem;
animation: ${downAnimate} var(--before-duration) linear infinite;
}
::after {
content: "";
position: absolute;
width: 10rem;
height: 10rem;
z-index: -1;
border-radius: 10rem;
background-color: var(--after-bgc);
right: -2rem;
bottom: -2rem;
animation: ${downAnimate} var(--after-duration) linear infinite;
}

:hover {
background: #18171794;
${Content} {
opacity: 1;
transform: translateY(0);
text-shadow: 1px 1px #ccc;
}
${Index},${Title} {
transform: translateY(-1rem);
color: #d3d0c3;
}
}
`;

const Wrap = styled.div`
width: 100%;
display: flex;
margin-bottom: 2rem;
display: flex;
justify-content: space-evenly;
flex-wrap: wrap;
`;


标签:const,linear,卡片,--,transform,content,styled,拖拽,3D
From: https://blog.51cto.com/u_15964288/6066507

相关文章

  • 3dmax专用卸载工具,完美彻底卸载清除干净3dmax各种残留注册表和文件
    3dmax专用卸载工具,完全彻底删除干净3dmax各种残留注册表和文件。有些同学由于一些原因想把3dmax卸载然后重新安装,但是发现3dmax安装到一半就失败了或者显示已安装或者未完......
  • Qt Quick 3D - 索引
    QtQuick3D 1.QtQuick3D-开篇2.QtQuick3D-搭建一个基本的3D场景3.QtQuick3D-模型的导入并加载4.QtQuick3D-实现车道线-1(顶点着色器控制曲率变化)......
  • Qt Quick 3D - 实现车道线 - 2(片元着色器控制虚实线)
    QtQuick3D-实现车道线-2(片元着色器控制虚实线)1.导入车道线模型。(这里不再赘述,自行参考该文档:QtQuick3D-模型的导入并加载)2.CustomMaterial  这是QtQui......
  • Qt Quick 3D - 实现车道线 - 3(shader控制远近端虚化效果)
    QtQuick3D-实现车道线-3(远近端虚化效果)1.俩种方式  1.1一种是在顶点着色器里面通过计算远近端的顶点,并根据pos数值,进行除法计算,得到一个比例,再与color数值相......
  • Qt Quick 3D - 实战(ADAS场景)
    QtQuick3D-实战(ADAS场景、3D中控车辆展示)1.此篇介绍大致内容,后续会建一个仓库2.ADAS场景实战内容如下:  2.1车道线随信号数据进行曲率变化  2.2车道线随信......
  • NSDT可编程3D场景
    推荐:将 NSDT场景编辑器 加入你的3D开发工具链。NSDT编辑器简化了WebGL3D应用的开发,完全兼容Three.JS生态。本文介绍如何在自己的应用中嵌入使用NSDT编辑器搭建的3D场......
  • [CF983D]Arkady and Rectangles
    \(\text{Solution}\)二维平面很容易想到扫描线,然后不知道维护什么信息颜色的变化自然要能记录下来,所以线段树每个结点维护一个set表示覆盖这个点代表区间的所有颜色这......
  • 万字长文概述单目3D目标检测算法
    一,理论基础-相机与图像1.1,单目相机介绍1.2,针孔相机模型1.3,坐标系间的欧式变换1.4,世界坐标与像素坐标的转换1.5,三维旋转:欧拉角、旋转矩阵之间的转换二,单目3D目标......
  • 单目3D目标检测综述
    一,理论基础-相机与图像相机将三维世界中的坐标点(单位为米)映射到二维图像平面(单位为像素)的过程能够用一个几何模型进行描述,这个模型有很多种,其中最简单的称为针孔相机模型。......
  • AntDesign中card卡片动态添加bodystyle样式,实现body切换
    业务效果核心代码<template><a-layoutclass="layout"><a-layout-headerclass="header"style="height:50px"><divclass="wrappercontent">......