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

172
Vistas
White space between slides in component carousel

I created a component carousel, everything is working fine but the second slide has unnecessary white space on top of it. How can I remove this? I've tried inspecting the website to find a possible solution, but the carousel always takes up the same amount of space. On the second slide though, it adds white space on top of it without increasing the size of the container. First Slide

Second slide Carousel.js:

const Carousel = ({ children }) => {
  const [activeIndex, setActiveIndex] = useState(0);

  const updateIndex = (newIndex) => {
    if (newIndex < 0) {
      newIndex = 0;
    } else if (newIndex >= React.Children.count(children)) {
      newIndex = React.Children.count(children) - 1;
    }
    setActiveIndex(newIndex);
  };

  return (
    <div className="overflow-hidden h-screen relative">
      <div
        className="whitespace-nowrap"
        style={{
          transform: `translateX(-${activeIndex * 100}%)`,
          transition: "transform 0.3s",
        }}
      >
        {React.Children.map(children, (child, index) => {
          return React.cloneElement(child, { width: "100%" });
        })}
      </div>
      <div className="flex justify-center absolute z-50 bottom-0">
        <button
          className="m-1 z-50"
          onClick={() => updateIndex(activeIndex - 1)}
        >
          Prev
        </button>
        <button
          className="m-1 z-50"
          onClick={() => updateIndex(activeIndex + 1)}
        >
          Next
        </button>
      </div>
    </div>
  );
};

CarouselItem.js:

const CarouselItem = ({ children, width }) => {
  return (
    <div
      className="inline-flex items-center justify-center h-screen bg-green-600 text-white"
      style={{ width: width }}
    >
      {children}
    </div>
  );
};
about 4 years ago · Juan Pablo Isaza
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