【问题标题】:bootstrap carousel not displaying images引导轮播不显示图像
【发布时间】:2016-11-19 00:11:27
【问题描述】:

我的轮播没有显示图像。我在文件夹名称 images 中存储了 3 张图像。我正在使用引导程序 4,让我知道出了什么问题。我还想知道我是否要插入分辨率低于 900*500 的图像.

1-ronald.jpg of 634 * 424 then

2-messi.jpg of 594 *432 和最后一个

620 * 348 分辨率的 3-pogba.jpg

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">

 <style type="text/css">


.carousel-inner > .carousel-item > img {
        padding-top:35px;
    margin: 0 auto;
    border-radius: 10px 10px 10px 10px;
    
    max-height: 500px;
    width: 750px;  
   
}



.carousel-control.left, .carousel-control.right {
    background-image: none;


}
#carousel
{
  margin-bottom: 50px;

}
</style>
<div id="carousel-example" class="carousel slide" data-ride="carousel">
  <ol class="carousel-indicators">
    <li data-target="#carousel-example" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example" data-slide-to="1"></li>
    <li data-target="#carousel-example" data-slide-to="2"></li>
  </ol>
  <div class="carousel-inner" role="listbox">
    <div class="carousel-item active">
      <img data-src="images/ronaldo1.jpg" alt="First slide">
    </div>
    <div class="carousel-item">
      <img data-src="images/pogba.jpg" alt="Second slide">
    </div>
    <div class="carousel-item">
      <img data-src="images/messi.jpg" alt="Third slide">
    </div>
  </div>
  <a class="left carousel-control" href="#carousel-example" role="button" data-slide="prev">
    <span class="icon-prev" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#carousel-example" role="button" data-slide="next">
    <span class="icon-next" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>

<!-- jQuery first, then Bootstrap JS. -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
    <script language="JavaScript" type="text/javascript">

【问题讨论】:

  • 你的最后一个“脚本”标签是什么???
  • 在运行 sn-p 时,我看到 Bootstrap 工具提示需要 Tether 错误,您是否包含了 Tether 所需的文件?
  • 脚本标签里什么都没有,只是打开和关闭而已。

标签: javascript jquery html css twitter-bootstrap


【解决方案1】:

在您的&lt;img&gt; 标签中

 <img data-src="images/pogba.jpg" alt="Second slide">

data-src 更改为 src

 <img src="images/pogba.jpg" alt="Second slide">

这样标记可以找到图像。

data-用于存储纯数据文本。

检查working JSFiddle

【讨论】:

  • 嘿,工作得很好,谢谢,但图像出现在最左上角,不知道如何将它们置于中心位置。
  • Check jsfiddle.net/fy9rfg22/1 添加了新的 CSS 规则。此外,如果您也想将它们垂直居中,您可以去掉第一条规则中的“高度”,使其自动适合图像。
  • 我已编辑 css 以在图像上获得圆角。我添加了边框半径,但它不适用于图像的顶部。您可以提供任何帮助。谢谢。
【解决方案2】:

在包含之前尝试包含 tether.min.js 脚本 bootstrap.min.js 脚本。

How to fix the error; 'Error: Bootstrap tooltips require Tether (http://github.hubspot.com/tether/)'

【讨论】:

    【解决方案3】:

    @yuriy636 解决方案工作正常,如果还没有工作,请检查图像权限。如果文件没有权限,可能需要一段时间浏览器才能加载该文件。

    【讨论】:

      猜你喜欢
      • 2020-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多