Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

119
Visualizações
Swiper js slidesPerView: "auto" goes off the window when swiping

I am trying to achieve this layout but when I try at first it seems ok but when you swipe, slide goes off. I want the active slide width to be 50% and others 25% at any window size except mobile. Layout

My scss looks like this. (I tried to change the active slide's width to 50% and others to 25%)

.newsSlider {
.swiper-slide {
    overflow: hidden;
    transition: 0.3s ease-in-out;
    width: 25%;

    .news-item {
        transition: 0.3s ease-in-out;
        width: 400px;
        height: 500px;
        overflow: hidden;
        position: relative;

        .news-floater {
            position: absolute;
            left: 0;
            bottom: 3rem;
            color: #fff;
            width: 100%;
            padding: 0 1rem 0 2rem;
            pointer-events: none;
            z-index: 2;

            .title {
                background-color: #cb2828;
                font-weight: bold;
                font-size: 1.3rem;
                text-transform: uppercase;
            }

            .news-title {
                font-size: 1.5rem;
                font-weight: bold;
            }

            .news-text {
                position: relative;
            }
        }

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
            transform: scale(1.2) translateX(0);
            transition: 5s ease-in-out;
        }
    }

    &.swiper-slide-active {
        width: 50%;

        .news-item {
            width: 100%;
            transition: 0.3s ease-in-out;

            .news-floater {
                pointer-events: all;
            }

            img {
                transform: scale(1.3) translateX(20px);
            }
        }
    }
}

}

Here is the demo: https://codepen.io/Xteripus/pen/yLpbJmQ

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda