我想在bootstrap和php中获取图像的弹出窗口

时间:2015-10-07 09:57:42

标签: php twitter-bootstrap

这是我通过PHP和Bootstrap获取图片库的代码。工作正常但我想在用户点击该特定图像时获得图像的弹出窗口。我可以在此代码中添加任何功能吗?

提前致谢

<h3>Photo Gallery</h3>
<ul id="categories">
<li>
<a href="javascript:void(0);" data-filter=".resort" onClick="makeCall('Resort');" class="Resort active">1</a>
</li>
<li class="rooms">
<a href="javascript:void(0);" data-filter=".beach" onClick="makeCall('Rooms');" class="Rooms">2</a>
 </li>
<li>
<a href="javascript:void(0);" data-filter=".beach" onClick="makeCall('Dinning');" class="Dinning">3</a>
</li>
<li>
<a href="javascript:void(0);" data-filter=".beach" onClick="makeCall('Swiming-Pool');" class="Swiming-Pool">4</a>
 </li>
<li class="last">
<a href="javascript:void(0);" data-filter=".beach" onClick="makeCall('all');" class="all">View all</a>
</li>
</ul>

<div class="row gallery gallery-section" id="demoLightbox" class="lightbox hide fade"  tabindex="-1" role="dialog" aria-hidden="true">
    <div class='lightbox-content'>
  <?php

  $path = 'images/gallery/'; // Create initial "Folders" array
  $filetype = '*.*';
  $_POST['type']='all';
  if($_POST['type']!='all')
  {
    $classloop[] = $_POST['type'];
    $folders[]=ucfirst($_POST['type']);
    $start=0;
    $foldercount = count($folders)-1;
  }
  else
  {
    if ($dir = opendir($path))
    {
        $j = 0;
        while (($file = readdir($dir)) !== false)
        {
            if ($file != '.' && $file != '..' && is_dir($path.$file))
            {
                $j++;
                $folders[$j] = $file;
            }
        }
    }
    $classloop = array("","","resort","envato");
    $start=1;
    $foldercount = count($folders);
 }

 for ($i = $start; $i <= $foldercount ; $i++)
 {
    $folderpath = $path.$folders[$i];
    $images = glob($folderpath."/".$filetype);
    $count = count($images);
    if($count>0)
    {
      for ($j = 0; $j < $count; $j++)
        { ?>
        <?php
          $z = $j%3;

          echo '<div class="'.$folders[$i].' photo-item hover test" style="float:left;">';

          echo '<a href="'.$images[$j].'" class="image-box">';

          echo '<div class="photo">';

          echo '<span class="text"><span class="anchor"></span></span>';

          echo '</div>';

          echo '<img src="'.$images[$j].'" alt=""  width="260"  height="170"/>';

          echo ' </a></div>';

          echo '<div class="col-md-4 col-sm-4 col-xs-6"><a href="#demoLightbox" class="gphoto" data-toggle="lightbox">';
          echo '<img src="images/delux.jpg" class="img-responsive" alt="" />';
          echo '</a></div>';

        }
    }
    else
    {
        echo '<div align="center" style="width: 100%;">No image(s) found</div>';
    }
}
?>

</div>

</div>
</div>
</div>
</section>

2 个答案:

答案 0 :(得分:1)

是啊..

将其放在css中

 <style type="text/css">
    /* popup_box DIV-Styles*/
    #popup_box { 
        display:none; /* Hide the DIV */
        position:fixed;  
        _position:absolute; /* hack for internet explorer 6 */  
        height:auto;  
        width:600px;  
        /*background:#FFFFFF;*/  
        left: 450px;
        top:63px;
        z-index:100; /* Layering ( on-top of others), if you have lots of layers: I just maximized, you can change it yourself */
        margin-left: 0px;  

        /* additional features, can be omitted */
        /*border:2px solid #ff0000; */
        padding:0px;  
        font-size:15px;  
        -moz-box-shadow: 0 0 15px #FF3333;
        -webkit-box-shadow: 0 0 15px #0033FF;
        box-shadow: 0 0 25px #990000;

    }

    a{  
        cursor: pointer;  
        text-decoration:none;  
    } 

    /* This is for the positioning of the Close Link */
    #popupBoxClose {
        font-size:20px;  
        line-height:15px;  
        right:5px;  
        top:5px;  
        position:absolute;  
        color:#6fa5e2;  
        font-weight:500;    
    }
</style>

制作一个高于id的div

点击按钮

附加javascript功能

打开弹出窗口

<button type="button" class="open" data-dismiss="modal" aria-label="Open" onclick="return loadPopupBox();"><span aria-hidden="true">Open</span></button>

关闭弹出窗口

<button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="return unloadPopupBox();"><span aria-hidden="true">×</span></button>

写一些javascript

function unloadPopupBox() {

    $('#yourdiv').hide();
}

function loadPopupBox(data) {   // To Load the Popupbox

        $('#yourdiv').show();
    });

确保您在加载页面时隐藏div。

答案 1 :(得分:0)

如果你的意思是点击时出现的模态,就有了,而我在这里实际上是你可以使用(或不使用)的template你可以玩的。 / p>