tailwind css overflow hidden doesn't working in animation

UNRIVALLEDKING

I'm trying to animate an image by moving to different positions. but whenever it goes beyond the screen. the scrollbar appears. I tried adding overflow hidden in the parent element but it didn't worked. here is the required code snippet. I'm using tailwind css with nextjs

page.js

<main className="flex min-h-screen  items-center">
      <div className="container mx-auto flex">
        <div className="z-50 w-1/2">
          <h1 className="m-0 p-0 text-9xl">
            <span>{Title.slice(0, 2)}</span>
            <span className="text-secondary">{Title.slice(2)}</span>
          </h1>
        </div>
        <div className=" w-/2">
          <Image
            className="absolute z-10 animate-leftToRight"
            src={whiteCircle}
            alt="white circle"
          />
        </div>
      </div>
    </main>

tailwind.config.js

theme: {
    extend: {
      colors: {
        primary: "#1c2340",
        secondary: "#f27eb2",
      },
      fontFamily: {
        Josefin: ["Josefin Sans", "sans-serif"],
        Poppins: ["Poppins", "sans-serif"],
      },
      animation: {
        leftToRight: "leftToRight 10s ease-in-out infinite",
      },
      keyframes: {
        leftToRight: {
          "0%, 100%": { left: "40%", top: "-20%", rotate: "0deg" },
          "50%": { left: "93%", top: "50%", rotate: "180deg" },
        },
      },
    },
  },

layout.js

<html lang="en">
      <body className="font-Poppins overflow-hidden max-w-[100vw] bg-primary text-white">
        <Navbar />
        <div className="mt-[60px]">{children}</div>
        <Footer />
      </body>
    </html>

As you can see in this image that white circle is at top and there isn't vertical scroll As you can see in this image that white circle is at top and there isn't vertical scroll

now as soon as the image goes beyond the screen scroll appears

enter image description here

stickyuser

You need to add overflow-hidden to the stacking context. At the moment that is the html element so you could add to globals.css:

html {
  @apply overflow-hidden;
}

Or you could create a new stacking context with relative and add the overflow hidden to that.

<main class="flex min-h-screen items-center relative overflow-hidden">

Exampe: https://play.tailwindcss.com/O8dHHydayG

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related