画像のようなスライドをswiperで作る方法を教えて下さい。
3つのスライドを包括するスライドが1つあり(画像の矢印ボタンで動く)
1つずつのスライドもページネーションバーによって切り替えできる(3つの黒丸)入れ子構造のスライドを作りたいのですが可能でしょうか。調べてみても出てこず苦戦しています。
質問内容を実現しているサイトを見つけ、同じように記述してみましたが、私の方ではページネーションバーが反応しない、アローボタンが表示されないといった問題が発生してしまいました。
現在はswiper-slideを3つ記述し、それを囲むswiper-slideを記述した状態で、script文も存在していますが動きません……。
head
1 <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.css" /> 2 <link rel="stylesheet" href="https://unpkg.com/swiper/swiper-bundle.min.css" />
HTML
1 <section class="top_okashi io fade upS move"> 2<div class="slide_carousel swiper-container io fade upS swiper-container-initialized swiper-container-horizontal move"> 3<div class="swiper-wrapper" style="transition-duration: 0ms; transform: translate3d(0px, 0px, 0px);"> 4<div class="swiper-slide okashi_list_item swiper-slide-active" style="width: 450px; margin-right: 20px;"> 5<div class="okashi_list_item io fade upS move"> 6<div class="slide_okashi_wrap"> 7<div class="slide_okashi swiper-container swiper-container-initialized swiper-container-horizontal"> 8<div class="swiper-wrapper" style="transition-duration: 0ms; transform: translate3d(0px, 0px, 0px);"> 9<div class="swiper-slide swiper-slide-active"><img alt="" class="swiper-lazy swiper-lazy-loaded" src="img/product_01.jpg"></div> 10<div class="swiper-slide swiper-slide-next"><img alt="" class="swiper-lazy swiper-lazy-loaded" src="img/product_01.jpg"></div></div> 11<div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets"><span class="swiper-pagination-bullet swiper-pagination-bullet-active" 12tabindex="0" role="button" aria-label="Go to slide 1"></span> 13<span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 2"></span></div> 14<svg class="arrow_left swiper-button-disabled" tabIndex="0" role="button" aria-label="Previous slide" aria-disabled="true"> 15<use xlink:href="#arrow_large1_left"></use></svg> 16<svg class="arrow_right" tabIndex="0" role="button" aria-label="Next slide" aria-disabled="false"> 17<use xlink:href="#arrow_large1_right"></use></svg> 18<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span></div> 19<a href="" target="_blank" class="okashi_shop" rel="noopener noreferrer"><svg class="icon_shop"> 20<use xlink:href="#icon_shop"></use></svg></a> 21<span class="badge winter"></span> 22<span class="badge spring"></span></div> 23<strong>タイトル</strong> 24<p>テキストテキストテキスト</p></div></div> 25<div class="swiper-slide okashi_list_item swiper-slide-next" style="width: 450px; margin-right: 20px;"> 26<div class="okashi_list_item io fade upS move"> 27<div class="slide_okashi_wrap"> 28<div class="slide_okashi swiper-container swiper-container-initialized swiper-container-horizontal"> 29<div class="swiper-wrapper" style="transition-duration: 0ms; transform: translate3d(0px, 0px, 0px);"> 30<div class="swiper-slide swiper-slide-prev"><img alt="" class="swiper-lazy swiper-lazy-loaded" src="img/product_01.jpg"></div> 31<div class="swiper-slide swiper-slide-active"><img alt="" class="swiper-lazy swiper-lazy-loaded" src="img/product_01.jpg"></div></div> 32<div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets"> 33<span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 1"></span> 34<span class="swiper-pagination-bullet swiper-pagination-bullet-active" tabindex="0" role="button" aria-label="Go to slide 2"></span></div> 35<svg class="arrow_left" tabIndex="0" role="button" aria-label="Previous slide" aria-disabled="false"> 36<use xlink:href="#arrow_large1_left"></use></svg> 37<svg class="arrow_right swiper-button-disabled" tabIndex="0" role="button" aria-label="Next slide" aria-disabled="true"> 38<use xlink:href="#arrow_large1_right"></use></svg> 39<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span></div> 40<a href="" target="_blank" class="okashi_shop" rel="noopener noreferrer"><svg class="icon_shop"> 41<use xlink:href="#icon_shop"></use></svg></a> 42<span class="badge winter"></span> 43<span class="badge autumn"></span></div> 44<strong>タイトル</strong> 45<p>テキストテキストテキスト</p></div></div> 46<div class="swiper-slide okashi_list_item" style="width:450px;" margin-right: 20px;> 47<div class="okashi_list_item io fade upS move"> 48<div class="slide_okashi_wrap"> 49<div class="slide_okashi swiper-container swiper-container-initialized swiper-container-horizontal"> 50<div class="swiper-wrapper"> 51<div class="swiper-slide swiper-slide-active"><img alt="" class="swiper-lazy swiper-lazy-loaded" src="img/product_01.jpg"></div> 52<div class="swiper-slide swiper-slide-next"><img alt="" class="swiper-lazy swiper-lazy-loaded" src="img/product_01.jpg"></div> 53<div class="swiper-slide"><img class="swiper-lazy"> 54<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div> </div> 55<div class="swiper-slide"><img class="swiper-lazy"> 56<div class="swiper-lazy-preloader swiper-lazy-preloader-white"></div></div></div> 57 58<div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets"> <span class="swiper-pagination-bullet swiper-pagination-bullet-active" tabindex="0" role="button" aria-label="Go to slide 1"></span> 59<span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 2"></span> 60<svg class="arrow_left swiper-button-disabled" tabIndex="0" role="button" aria-label="Previous slide" aria-disabled="true"> <use xlink:href="#arrow_large1_left"></use></svg> 61<svg class="arrow_right" tabIndex="0" role="button" aria-label="Next slide" aria-disabled="false"> 62<use xlink:href="#arrow_large1_right"></use></svg> 63<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span></div> 64<a href="" target="_blank" class="okashi_shop" rel="noopener noreferrer"> 65<svg class="icon_shop"> 66<use xlink:href="#icon_shop"></use></svg></a> 67<span class="badge winter"></span> 68<span class="badge autumn"></span></div> 69<strong>タイトル</strong> 70<p>テキストテキストテキスト</p> 71</div> 72</div> 73</div> 74</section>
javascript
1<script type="text/javascript"> 2 3 var swiperSeasonal = new Swiper ('.slide_carousel', { 4 loop: false, 5 speed: 800, 6 slidesPerView: 2, 7 centeredSlides : true, 8 spaceBetween: 30, 9 navigation: { 10 nextEl: '.slide_carousel > .arrow_right', 11 prevEl: '.slide_carousel > .arrow_left', 12 }, 13 breakpoints: { 14 768: { 15 slidesPerView: 1, 16 spaceBetween: 20, 17 } 18 }, 19 }); 20 21 //個別スライド 22 var swiperOkashi = new Swiper ('.slide_okashi', { 23 nested:true, 24 speed: 600, 25 watchOverflow: true, 26 pagination: { 27 el: '.slide_okashi .swiper-pagination', 28 clickable: true, 29 }, 30 navigation: { 31 nextEl: '.slide_okashi > .arrow_right', 32 prevEl: '.slide_okashi > .arrow_left', 33 }, 34 preloadImages: false, 35 lazy: { 36 loadPrevNext: true, 37 loadOnTransitionStart: true, 38 }, 39 }); 40 </script> 41
文字数削減のため、HTMLのコードがインデント処理出来ておりませんが、ご了承ください。
引き続き、ご回答お待ちしております。