如何使bootstrap 4轮播响应?

时间:2017-12-11 18:33:53

标签: bootstrap-4

我的旋转木马没有响应?当我缩小页面时,所有页面都响应,但旋转木马图像保持相同的大小。我很困惑要改变/修复什么来调整这个,有人可以看看我的代码,看看问题出在哪里了吗?我从getbootstrap中获取了确切的代码,所以我不确定为什么会出现这个问题。

<!doctype html>
<html lang="en">
  <head>
    <title>Cars</title>
    <!-- Required meta tags -->
    <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-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
     <link rel="stylesheet" href="animate.css">
     <link rel="stylesheet" href="custom.css">
     <link rel="stylesheet" href="icon.css">
     <link rel="stylesheet" href="styles.css">
  </head>

  <body>
    <header>
          <nav class="navbar navbar-expand-sm navbar-dark">
      <a class="navbar-brand" href="index.html">Cars</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExample03" aria-controls="navbarsExample03" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarsExample03">
        <ul class="navbar-nav mr-auto">
          <li class="nav-item active">
            <a class="nav-link" href="index.html">Home <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown03" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Sports Cars</a>
            <div class="dropdown-menu" aria-labelledby="dropdown03">
              <a class="dropdown-item" href="s2000.html">Honda S2000</a>
              <a class="dropdown-item" href="m3.html">BMW M3</a>
              <a class="dropdown-item" href="corvette.html">Chevrolet Corvette</a>
            </div>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown03" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Exotic Cars</a>
            <div class="dropdown-menu" aria-labelledby="dropdown03">
              <a class="dropdown-item" href="agera.html">Koenigsegg Agera</a>
              <a class="dropdown-item" href="nsx.html">Acura NSX</a>
              <a class="dropdown-item" href="ford.html">Ford GT</a>
            </div>
          </li>
        </ul>
        <form class="form-inline my-2 my-md-0">
          <input class="form-control" type="text" placeholder="Search">
        </form>
      </div>
    </nav>
      </header>

          <main role="main">

      <div id="myCarousel" class="carousel slide" data-ride="carousel">
        <ol class="carousel-indicators">
          <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
          <li data-target="#myCarousel" data-slide-to="1"></li>
          <li data-target="#myCarousel" data-slide-to="2"></li>
        </ol>
        <div class="carousel-inner">
          <div class="carousel-item active">
            <img class="first-slide" src="nsx.jpg" alt="Red NSX">
            <div class="container">
              <div class="carousel-caption text-left">
                <p><a class="btn btn-lg btn-primary animated rubberBand" href="nsx.html" role="button">NSX <span class="icon-speedometer"></span></a></p>
                <button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom"> More info!</button>

              </div>
            </div>
          </div>
          <div class="carousel-item">
            <img class="second-slide" src="gt.jpg" alt="Gray Ford GT">
            <div class="container">
              <div class="carousel-caption">
              </div>
            </div>
          </div>
          <div class="carousel-item">
            <img class="third-slide" src="lambo.jpg" alt="Red Lamborghini">
            <div class="container">
              <div class="carousel-caption text-right">
              </div>
            </div>
          </div>
        </div>
        <a class="carousel-control-prev" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
          <span class="carousel-control-next-icon" aria-hidden="true"></span>
          <span class="sr-only">Next</span>
        </a>
      </div>

      <div class="container marketing">

      <br> <br>

        <div class="row">
          <div class="col-lg-4">
            <img class="rounded-circle" src="s2k.jpg" alt="Yellow S2000" width="140" height="140">
            <h3>S2000</h3>
            <p><ul>
              <li>Manufacture: Honda</li>
              <li>Production: 2000-2009</li>
              <li>Engine Size: 4 Cylinder</li>
              <li>Drivetrain: Rear Wheel Drive</li>
            </ul>
            </p>
            <p><a class="btn btn-secondary" href="s2000.html" role="button">View details &raquo;</a></p>
          </div><!-- /.col-lg-4 -->
          <div class="col-lg-4">
            <img class="rounded-circle" src="m3.jpg" alt="Silver M3" width="140" height="140">
            <h3>M3</h3>
            <p><ul>
              <li>Manufacture: BMW</li>
              <li>Production: 1985-Present</li>
              <li>Engine Size: 6-8 Cylinder</li>
              <li>Drivetrain: Rear Wheel Drive</li>
            </ul></p>
            <p><a class="btn btn-secondary" href="m3.html" role="button">View details &raquo;</a></p>
          </div><!-- /.col-lg-4 -->
          <div class="col-lg-4">
            <img class="rounded-circle" src="nsx.jpg" alt="red nsx" width="140" height="140">
            <h3>NSX</h3>
            <p><ul>
              <li>Manufacture: Acura</li>
              <li>Production: 1990-Present</li>
              <li>Engine Size: 6 Cylinder</li>
              <li>Drivetrain: Rear Wheel Drive</li>
            </ul></p>
            <p><a class="btn btn-secondary" href="nsx.html" role="button">View details &raquo;</a></p>
          </div><!-- /.col-lg-4 -->
          <div class="col-lg-4">
            <img class="rounded-circle" src="corvette.jpg" alt="Black Corvette" width="140" height="140">
            <h3>Corvette</h3>
            <p><ul>
              <li>Manufacture: Chevrolet</li>
              <li>Production: 1953-Present</li>
              <li>Engine Size: 8 Cylinder</li>
              <li>Drivetrain: Rear Wheel Drive</li>
            </ul></p>
            <p><a class="btn btn-secondary" href="corvette.html" role="button">View details &raquo;</a></p>
          </div><!-- /.col-lg-4 -->
          <div class="col-lg-4">
            <img class="rounded-circle" src="gt.jpg" alt="Gray ford GT" width="140" height="140">
            <h3>Ford GT</h3>
            <p><ul>
              <li>Manufacture: Ford</li>
              <li>Production: 2004-Present</li>
              <li>Engine Size: 8 Cylinder</li>
              <li>Drivetrain: Rear Wheel Drive</li>
            </ul></p>
            <p><a class="btn btn-secondary" href="ford.html" role="button">View details &raquo;</a></p>
          </div><!-- /.col-lg-4 -->
          <div class="col-lg-4">
            <img class="rounded-circle" src="agera.jpg" alt="blue agera" width="140" height="140">
            <h3>Agera</h3>
            <p><ul>
              <li>Manufacture: Koenigsegg</li>
              <li>Production: 2011-Present</li>
              <li>Engine Size: 8 Cylinder</li>
              <li>Drivetrain: Rear Wheel Drive</li>
            </ul></p>
            <p><a class="btn btn-secondary" href="agera.html" role="button">View details &raquo;</a></p>
          </div><!-- /.col-lg-4 -->
        </div><!-- /.row -->



      <!-- FOOTER -->
      <footer class="container">
        <p><button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
        Contact us <span class="icon-phone"></span></button>
        </p>
      <div class="collapse" id="collapseExample">
       <div class="card card-body">
        Email:Umar@qurashi.com
       </div>
      </div>
        <p class="float-right"><a href="index.html">Back to top</a></p>
        <p>&copy; 2017 Umar Qurashi</p>
      </footer>

    </main>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
  </body>
</html>

1 个答案:

答案 0 :(得分:2)

点击按钮&#34;运行代码段&#34;并看到它使用Bootstrap Responsive Carousel

&#13;
&#13;
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Bootstrap Responsive Carousel Example</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.6/umd/popper.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
      <style>
      /* Make the image fully responsive */
      .carousel-inner img {
          width: 100%;
          height: 100%;
      }
      </style>
    </head>
    <body>
    <div class="container">
    <h2>Responsive Carousel</h2> 
    
    <div id="demo" class="carousel slide" data-ride="carousel">
      <ul class="carousel-indicators">
        <li data-target="#demo" data-slide-to="0" class="active"></li>
        <li data-target="#demo" data-slide-to="1"></li>
        <li data-target="#demo" data-slide-to="2"></li>
      </ul>
      <div class="carousel-inner">
        <div class="carousel-item active">
          <img src="http://midtowncarpetcleaning.com/wp-content/themes/envision/lib/images/default-placeholder-1000x600.png" alt="Los Angeles" style="width:100%;">
          <div class="carousel-caption">
            <h3>Los Angeles</h3>
            <p>We had such a great time in LA!</p>
          </div>   
        </div>
        <div class="carousel-item">
          <img src="http://midtowncarpetcleaning.com/wp-content/themes/envision/lib/images/default-placeholder-1000x600.png" alt="Los Angeles" style="width:100%;">
          <div class="carousel-caption">
            <h3>Chicago</h3>
            <p>Thank you, Chicago!</p>
          </div>   
        </div>
        <div class="carousel-item">
          <img src="http://midtowncarpetcleaning.com/wp-content/themes/envision/lib/images/default-placeholder-1000x600.png" alt="Los Angeles" style="width:100%;">
          <div class="carousel-caption">
            <h3>New York</h3>
            <p>We love the Big Apple!</p>
          </div>   
        </div>
      </div>
      <a class="carousel-control-prev" href="#demo" data-slide="prev">
        <span class="carousel-control-prev-icon"></span>
      </a>
      <a class="carousel-control-next" href="#demo" data-slide="next">
        <span class="carousel-control-next-icon"></span>
      </a>
    </div>
    </div>
    
    </body>
    </html>
&#13;
&#13;
&#13;