Bootstrap4で設置が簡単なスライダーは標準のスライダー

Bootstrap4に用意されているスライダー、シンプルなスライダーで良ければ設置が簡単。

基本タグ

<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<!-- インジケータ 不要の場合ol~/ol削除 -->
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="https://placehold.it/800x500" alt="First slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://placehold.it/800x500" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://placehold.it/800x500" alt="Third slide">
    </div>
  </div>
<!-- スライドコントロール 不要の場合以下8行削除 -->
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

CDNで確認バージョン・・・単体で動きます

<!doctype html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Bootstrap4 CDN 基本HTML</title>
</head>
<body>
<!-- コンテンツ --> 
<div class="container">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
<!-- インジケータ 不要の場合ol~/ol削除 -->
  <ol class="carousel-indicators">
    <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
    <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner">
    <div class="carousel-item active">
      <img class="d-block w-100" src="https://placehold.it/800x500" alt="First slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://placehold.it/800x500" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img class="d-block w-100" src="https://placehold.it/800x500" alt="Third slide">
    </div>
  </div>
<!-- スライドコントロール 不要の場合以下8行削除 -->
  <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
    <span class="carousel-control-prev-icon" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
    <span class="carousel-control-next-icon" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
</div> 
<!-- /コンテンツ --> 
<!-- jquery -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<!-- Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

 

 

 

 

コメント

タイトルとURLをコピーしました