Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

320
Vistas
How can I use next.js image and attach it to the background?

I'm unable to create a fixed background image (parallex effect) using Tailwind CSS + Next.js Image.

You can see it in action on this Template Monster theme.

This is the code I have tried:

<section className="stats w-full h-48 relative">
  <div className="absolute top-0 right-0 bottom-0 left-0 object-cover bg-cover">
    <Image
      layout='fill'
      src={data.backgroundImageUrl}
    />
  </div>
  <div className="relative z-10 flex flex-col items-center">
    <div>Stat 1</div>
    <div>Stat 2</div>
    <div>Stat 3</div>
    <div>Stat 4</div>
  </div>
</section>

And it does not work. The image attaches to the section and there is no parallax effect.

I can replace it with:

  <div className="aboslute top-0 right-0 bottom-0 left-0 object-cover bg-cover"
    style={{
      backgroundImage: `url(${data.backgroundImageUrl})`
    }}
  />

And it works. But then it does not optimize the image and my SEO score drops in lighthouse.

How can I use next/image alongside TailwindCSS for parallax effect of section backgrounds?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can try something like this https://stackblitz.com/edit/nextjs-aye7nj?file=pages%2Findex.js Create wrapper with clipPath property and wrapper with fixed position.

<div
  style={{
    position: 'relative',
    height: '60vh',
    width: '100%',
    clipPath: 'inset(0 0 0 0)',
  }}
>
  <div
    style={{
      position: 'fixed',
      height: '100%',
      width: '100%',
      left: '0',
      top: '0',
    }}
  >
    <Image
      src="https://images.unsplash.com/photo-1630496128261-27ce4ab6ad76?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80"
      layout="fill"
      objectFit="cover"
      sizes="100vw"
    />
  </div>
</div>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda