卡片组件

1.先看效果

2.源代码

import { useState } from 'react'

import { motion } from 'framer-motion'

import { Button } from "@/components/ui/button"


export default function Component() {

const [isHovered, setIsHovered] = useState(false)


return (

className="w-full max-w-md bg-white rounded-xl shadow-2xl overflow-hidden transform transition-all duration-500 ease-in-out"

whileHover={{ scale: 1.05 }}

onHoverStart={() => setIsHovered(true)}

onHoverEnd={() => setIsHovered(false)}

>

src="/placeholder.svg?height=200&width=400"

alt="Beautiful landscape"

className="w-full h-48 object-cover"

/>

Discover Beauty

Embark on a journey through breathtaking landscapes and awe-inspiring vistas.

Let nature's beauty captivate your senses and inspire your soul.

initial={{ opacity: 0, scale: 0.5 }}

animate={{ opacity: isHovered ? 1 : 0, scale: isHovered ? 1 : 0.5 }}

transition={{ duration: 0.3 }}

>

Explore Now →

)

}

×
二维码

扫描二维码分享

评论区

登录后发表评论。