bootstrap image modal popup jquery php

时间:2015-06-10 08:23:30

标签: javascript jquery html css twitter-bootstrap

我正在构建一个模式来显示我的图像轮播。但它不起作用 - 弹出来,但没有图像。我需要帮助才能看到我的代码出了什么问题。它根本没有显示任何图像,即使我不知道是什么造成的。我想要实现的是,弹出点击产品菜单的图像。

图像位于将调用模态的视图中:

while

模式显示弹出图像:

<div id="carousel" class="carousel slide" data-ride="carousel">

  <div class="carousel-inner">

    <?php 
$banyak = 0;
$id = $results->id;
$barangNama = $results->nama;
$barangHarga1 = $results->harga;
$barangGambar = $results->gambar;
$barangMerk = $results->merk;
$barangCategory = $results->category;
$barangTipe = $results->tipe;
$barangDeskripsi = $results->deskripsi;

$barangHarga = number_format($barangHarga1);

$newGambar = explode(',',$barangGambar);
//print_r($newGambar);
?>

    <?php 
$w = 0;
for($i = 0; $i < count($newGambar); $i++) {


if($w % 4 == 0){
$banyak++;
}
$w++;
//echo $banyak;
?>
    <div class="item <?php if($i == 0){echo "active";} ?>" data-thumb="<?php echo $banyak-1; ?>">
      /* this is where i call the modal */  <a href="#" data-toggle="modal" data-target="#image-gallery">
      <img src="<?php echo base_url(); ?>assets/images/product_picture/<?php echo $newGambar[$i]; ?>" alt="asda">
      </a>    
    </div>
    <?php   
}
?>
    <a class="left carousel-control" href="#carousel" role="button" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left"></span>
    </a>
    <a class="right carousel-control" href="#carousel" role="button" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right"></span>
    </a>
  </div>
</div>

脚本:

<!-- Modal -->
<div class="modal fade" id="image-gallery" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">X</span><span class="sr-only">Close</span></button>
        <h4 class="modal-title" id="image-gallery-title"></h4>
      </div>
      <div class="modal-body">
        <img id="image-gallery-image" class="img-responsive" src="">
      </div>
      <div class="modal-footer">

        <div class="col-md-2">
          <button type="button" class="btn btn-primary" id="show-previous-image">Previous</button>
        </div>

        <div class="col-md-8 text-justify" id="image-gallery-caption">

        </div>

        <div class="col-md-2">
          <button type="button" id="show-next-image" class="btn btn-default">Next</button>
        </div>
      </div>
    </div>
  </div>
</div>

2 个答案:

答案 0 :(得分:0)

猜猜你已经评论了输出?

/usr/lib/gcc/x86_64-linux-gnu/4.8

答案 1 :(得分:0)

这是因为z-index值。检查网页。检查carousel的z-index。大多数开发人员在代码中放置-9999px和9999px值或类似值。

调整您的z-index值,以便模态框及其容器位于轮播顶部。

bootstrap modal css位于 bootstrap.css