Home >Web Front-end >JS Tutorial >Dynamic Head-Out Image Box Using React Tailwind CSS

Dynamic Head-Out Image Box Using React Tailwind CSS

DDD
DDDOriginal
2025-01-12 10:31:44361browse

Need a quick UI boost? ? Here’s a simple React Tailwind CSS snippet to create a stylish Head-Out Image Box.

Dynamic Head-Out Image Box Using React   Tailwind CSS

Code

// HeadOutImage.tsx
interface IProps {
  alt: string;
  src: string;
}

export default function HeadOutImage({ alt, src }: IProps) {
  return (
    <div className="group aspect-[7/9] h-auto w-full flex-[0_0_auto] self-start overflow-hidden border-b-2 border-white pt-20">
      <div className="size-full border-2 border-b-0 border-white bg-red-400/0 transition-colors duration-500 group-hover:bg-red-400/85" />
      <Image
        alt={alt}
        src={src}
        className="absolute -bottom-24 h-auto w-full border-2 border-transparent transition-all duration-500 ease-in-out group-hover:-bottom-20"
      />
    </div>
  );
}

Using group class and modifier, we can achieve cool effects as above. Copy, paste, done! ?️✨ You can also adjust displacement and customize it in a way you like!

The above is the detailed content of Dynamic Head-Out Image Box Using React Tailwind CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn