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

475
Vistas
Swiper: Set custom slide to active

I'm using Swiper to show a slider with every month of the year. It slides from left to right.

I now want to start with the current month on the left side. If there are month before, they should be in the left offset.

I tried to give the .swiper-slide class the active class .swiper-slide-active:

<div class="swiper-slide swiper-slide-active">

But that doesnt work.

In the docs I found no parameter to set a acive slide in the settings. Is there any way to do this?

Here's my current code: https://codepen.io/cray_code/pen/dydrLBP

var swiper = new Swiper(".swiper-months", {
    cssMode: false,
    slidesPerView: 3.5,
    spaceBetween: 16,
    activeIndex: 6,
    mousewheel: {
        forceToAxis: true,
    },
});

The activeIndex: 6 doesn't work either. I'm not sure if that's correct.

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

0

Try initialSlide, activeIndex is just for getting the actual active index. But I think you shoud use 5 insted of 6 to start on sixth month, because first month starts with 1 and indexing starts from 0.

var swiper = new Swiper(".swiper-months", {
    initialSlide: 6,
    cssMode: false,
    slidesPerView: 3.5,
    spaceBetween: 16,
    mousewheel: {
        forceToAxis: true,
    },
});
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