我无法使用引导程序将图像链接到我的轮播中主机上的页面

Posted

技术标签:

【中文标题】我无法使用引导程序将图像链接到我的轮播中主机上的页面【英文标题】:I cannot link images to pages on my host in my carousel with bootstrap 【发布时间】:2018-12-27 03:07:06 【问题描述】:

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

<!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" >
              </div>
              <div class="carousel-item">
                <img class="d-block img-fluid" src="img/sterlingsilverdaisychain900x350.jpg" href="sterlingsilverchainwithdaisies.html" >
              </div>
              <div class="carousel-item">
                <img class="d-block img-fluid" src="img/copperowl900x350.jpg" href="copperowlontwostrandcopperchain.html" >
              </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】:

天哪,甜甜的bajeezus!我用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" >
</a>
                  </div>
                  <div class="carousel-item">
<a href="sterlingilverdaisychain.html">
                    <img class="d-block img-fluid" src="img/sterlingsilverdaisychain900x350.jpg" >
</a>
                  </div>
                  <div class="carousel-item">
<a href="copperowlontwostrancopperchain.html">
                    <img class="d-block img-fluid" src="img/copperowl900x350.jpg" >
</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>

【讨论】:

以上是关于我无法使用引导程序将图像链接到我的轮播中主机上的页面的主要内容,如果未能解决你的问题,请参考以下文章

如何固定自定义轮播的大小

在轮播中反应原生视频

我正在尝试将 Vue 数据实现到 Bootstrap 轮播中

当我提出新请求时,Ajax http 请求将以前的图像加载到轮播中

在引导轮播中使用图像而不是幻灯片背景

如何仅在反应中使用引导程序(5.1v)中的轮播?