Задать вопрос

Как сделать вертикальный parallax на Swiper?

var swiper = new Swiper('.swiper-container', {
			direction: 'vertical',
			slidesPerView: 1,
			mousewheel: true,
			spaceBetween: 0,
			speed: 600,
			parallax: true,
			pagination: {
				el: '.swiper-pagination',
				clickable: true,
			},
			fadeEffect: {
				crossFade: true
			},
		});


.swiper-container {
        width: 100%;
        height: 100%;
        margin-left: auto;
        margin-right: auto;
    }
    .swiper-slide {
        text-align: center;
        font-size: 18px;
        /* Center slide text vertically */
        display: -webkit-box;
        display: -ms-flexbox;
        display: -webkit-flex;
        display: flex;
        -webkit-box-pack: center;
        -ms-flex-pack: center;
        -webkit-justify-content: center;
        justify-content: center;
        -webkit-box-align: center;
        -ms-flex-align: center;
        -webkit-align-items: center;
        align-items: center;
    }
	.swiper-pagination-bullet-active{
		background-color:#fff;
	}

	.parallax-bg {
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 123%;
      -webkit-background-size: cover;
      background-size: cover;
      background-position: center;
    }


<main id="main-page" class="swiper-container">
		<div class="swiper-wrapper">
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(http://allart.biz/up/photos/album/V/Vasnetsov%20Viktor/vasnetsov_a_knight_at_the_crossroads_1882.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 1</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(https://i.pinimg.com/originals/6d/69/04/6d6904a9d56a5bec124a797b9e6fd813.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 2</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(https://hague6185.files.wordpress.com/2015/01/post-28-1375877797.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 3</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(http://allart.biz/up/photos/album/V/Vasnetsov%20Viktor/vasnetsov_a_knight_at_the_crossroads_1882.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 4</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(https://i.pinimg.com/originals/6d/69/04/6d6904a9d56a5bec124a797b9e6fd813.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 5</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(https://hague6185.files.wordpress.com/2015/01/post-28-1375877797.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 6</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(http://allart.biz/up/photos/album/V/Vasnetsov%20Viktor/vasnetsov_a_knight_at_the_crossroads_1882.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 7</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(https://i.pinimg.com/originals/6d/69/04/6d6904a9d56a5bec124a797b9e6fd813.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 8</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(https://hague6185.files.wordpress.com/2015/01/post-28-1375877797.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 9</div>
			</div>
			<div class="swiper-slide">
				<div class="parallax-bg" style="background-image:url(http://allart.biz/up/photos/album/V/Vasnetsov%20Viktor/vasnetsov_a_knight_at_the_crossroads_1882.jpg);" data-swiper-parallax="23%"></div>
				<div class="title">Slide 10</div>
			</div>
		</div>
        <!-- Пагинация -->
        <div class="swiper-pagination"></div>
	</main>


Тупо картинка за картинкой идет и никакого эффекта паралакса нет у background. Может кто-то уже сталкивался с таким и может помочь
  • Вопрос задан
  • 1331 просмотр
Подписаться 1 Средний Комментировать
Пригласить эксперта
Ответы на вопрос 1
danielchistyakov
@danielchistyakov
Frontend Engineer
Возможно кому пригодится
https://codepen.io/karlovidek/pen/LQozGJ
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы