1. 全画面表示、実装サンプル(background対応)
しっかりレスポンシブ対応したいので『background』で画像を設定するのが一番です。
スワイプもできるのでおすすめです。
See the Pen
【jQuery】『slick』を使って全画面表示のスライドショー(background対応) by 125naroom (@125naroom)
on CodePen.
HTML
<div class="full"> <div class="main01"></div> <div class="main02"></div> <div class="main03"></div> </div>
CSS
.full div { background-repeat: no-repeat; background-size: cover; background-position: center; height: 100vh; margin: 0; } .full div.img01 { background-image: url(https://125naroom.com/demo/img/simple01.jpg); } .full div.img02 { background-image: url(https://125naroom.com/demo/img/simple02.jpg); } .full div.img03 { background-image: url(https://125naroom.com/demo/img/simple03.jpg); } .full .slick-dots { bottom: 4%; z-index: +1; }
jQuery
$(document).on('ready', function() { $(".full").slick({ arrows: false, dots: true, autoplay: true, autoplaySpeed: 1500, speed: 1500, fade: true, pauseOnFocus: false, pauseOnHover: false, pauseOnDotsHover: false, }); });
2. 全画面表示、実装サンプル(background対応、aタグを使えばリンクもOK)
スワイプもできてリンクも貼れてslickさん素晴らしいの一言です。
See the Pen
【jQuery】『slick』を使って全画面表示のスライドショー(background対応、aタグを使えばリンクもOK) by 125naroom (@125naroom)
on CodePen.
HTML
<div class="full"> <a href="https://125naroom.com/web/3486" target="_blank" class="img01"></a> <a href="https://125naroom.com/web/3486" target="_blank" class="img02"></a> <a href="https://125naroom.com/web/3486" target="_blank" class="img03"></a> </div>
CSS
.full a { background-repeat: no-repeat; background-size: cover; background-position: center; height: 100vh; margin: 0; text-decoration: none; } .full a.img01 { background-image: url(https://125naroom.com/demo/img/simple01.jpg); } .full a.img02 { background-image: url(https://125naroom.com/demo/img/simple02.jpg); } .full a.img03 { background-image: url(https://125naroom.com/demo/img/simple03.jpg); } .full .slick-dots { bottom: 4%; z-index: +1; }
jQuery
$(document).on('ready', function() { $(".full").slick({ arrows: false, dots: true, autoplay: true, autoplaySpeed: 1500, speed: 1500, fade: true, pauseOnFocus: false, pauseOnHover: false, pauseOnDotsHover: false, }); });
メモ
jQueryのことで何かわからないことがあればjQueryの日本語リファレンスサイトがあるので一度チェックしてみるといろいろ解決できたりしますよ。
さいごに
関連記事
【jQuery】iOS(Safari)だと100vhが少しはみ出てしまう対策
【jQuery】スライダープラグイン「slick」実装サンプル集