Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

120
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!