我无法使用引导程序将图像链接到旋转木马中主机上的页面

时间:2018-07-19 05:17:29

标签: jquery html twitter-bootstrap bootstrap-4 carousel

我正在尝试将轮播中的图片链接到网站上的页面。我在这里查看了其他答案(Href in Bootstrap Carousel),在需要的地方添加了href,并从引导站点中获得了正确的.js。该链接与该页面位于同一主机上,因此它至少应让我可以选择单击它并转到错误的页面(404),但它的行为甚至根本不像链接一样,没有任何选择甚至单击它。我还尝试了指向网页本身http://mywebsite.com/pageiwant的链接。我对此很陌生,我只是在短时间内使用HTML。我可能做错了什么?我正在使用Bootstrap4。在此先谢谢您!

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    
    <link rel="stylesheet" href="css/bootstrap.min.css"> 
    
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="js/bootstrap.min.js"></script>
    
  </head>
  <body>

<div class="container">		
			
        <div class="col-lg-9 col-centered align-right">

          <div id="carouselExampleIndicators" class="carousel slide my-4" data-ride="carousel">
            <div class="carousel-inner" role="listbox">
              <div class="carousel-item active">
                <img class="d-block img-fluid" src="img/peridotandprehnite900x350.jpg" href="peridotandprehnite.html" alt="First slide">
              </div>
              <div class="carousel-item">
                <img class="d-block img-fluid" src="img/sterlingsilverdaisychain900x350.jpg" href="sterlingsilverchainwithdaisies.html" alt="Second slide">
              </div>
              <div class="carousel-item">
                <img class="d-block img-fluid" src="img/copperowl900x350.jpg" href="copperowlontwostrandcopperchain.html" alt="Third slide">
              </div>
            </div>
            <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>
          
    <footer class="py-2 bg-color:#7EC1BD fixed-bottom">
      <div class="container">
        <p class="m-0 text-center text-white">Meow Meow Meow</p>
      </div>
      <!-- /.container -->
    </footer>

</body>
</html>

1 个答案:

答案 0 :(得分:0)

圣洁的甜甜甜甜的宝贝!我用How do I add a links to pictures in Twitter Bootstrap Carousel?弄清楚了。通过将每个图像包装到href中,它现在可以正常工作!

<!doctype html>
    <html lang="en">
      <head>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        
        <link rel="stylesheet" href="css/bootstrap.min.css"> 
        
        <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
        <script src="js/bootstrap.min.js"></script>
        
      </head>
      <body>

    <div class="container">		
    			
            <div class="col-lg-9 col-centered align-right">

              <div id="carouselExampleIndicators" class="carousel slide my-4" data-ride="carousel">
                <div class="carousel-inner" role="listbox">
                  <div class="carousel-item active">
<a href="peridotandprehnite.html">
                    <img class="d-block img-fluid" src="img/peridotandprehnite900x350.jpg" alt="First slide">
</a>
                  </div>
                  <div class="carousel-item">
<a href="sterlingilverdaisychain.html">
                    <img class="d-block img-fluid" src="img/sterlingsilverdaisychain900x350.jpg" alt="Second slide">
</a>
                  </div>
                  <div class="carousel-item">
<a href="copperowlontwostrancopperchain.html">
                    <img class="d-block img-fluid" src="img/copperowl900x350.jpg" alt="Third slide">
</a>
                  </div>
                </div>
                <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>
              
        <footer class="py-2 bg-color:#7EC1BD fixed-bottom">
          <div class="container">
            <p class="m-0 text-center text-white">Meow Meow Meow</p>
          </div>
          <!-- /.container -->
        </footer>

    </body>
    </html>