Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/418.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript函数激活lightbox,在photogallery上使用弹出窗口_Javascript_Css - Fatal编程技术网

使用javascript函数激活lightbox,在photogallery上使用弹出窗口

使用javascript函数激活lightbox,在photogallery上使用弹出窗口,javascript,css,Javascript,Css,我似乎无法让我的照片库正常工作时,点击它。我正在尝试使用java函数使lightbox类型生效 这是我的密码: <div style="max-width: 888px; width: 100%; margin: 0 auto; text-align: center;" id="thumbnails"> $images_dir = 'images/med/full/'; $thumbs_dir = 'images/med/thumb/'; $thumbs_width = 300; $

我似乎无法让我的照片库正常工作时,点击它。我正在尝试使用java函数使lightbox类型生效

这是我的密码:

<div style="max-width: 888px; width: 100%; margin: 0 auto; text-align: center;" id="thumbnails">
$images_dir = 'images/med/full/';
$thumbs_dir = 'images/med/thumb/';
$thumbs_width = 300;
$thumbs_height = 300;
$images_per_row = 3;

/** generate photo gallery **/
$image_files = get_files($images_dir);
if(count($image_files)) {
$index = 0;
foreach($image_files as $index=>$file) {
$index++;
$thumbnail_image = $thumbs_dir.$file;
if(!file_exists($thumbnail_image)) {
    $extension = get_file_extension($thumbnail_image);
    if($extension) {
        make_thumb  ($images_dir.$file,$thumbnail_image,$thumbs_width,$thumbs_height);
    }
}
echo '<a href="',$images_dir.$file,'" class="photo-link smoothbox" rel="gallery"><img src="',$thumbnail_image,'" /></a>';
if($index % $images_per_row == 0) { echo '<div class="clear"></div>'; }
}
echo '<div class="clear"></div>';
}
else {
echo '<p>There are no images in this gallery.</p>';
}

?>
</div>

$images_dir='images/med/full/';
$thumbs_dir='images/med/thumb/';
$thumbs_width=300;
$thumbs_高度=300;
$images\u/行=3;
/**生成照片库**/
$image\u files=获取文件($images\u dir);
如果(计数($image_文件)){
$index=0;
foreach($index=>$file形式的图像文件){
$index++;
$thumbnail\u image=$thumbs\u dir.$file;
如果(!file_存在($thumbnail_image)){
$extension=get_file_extension($thumbnail_image);
如果($延期){
制作拇指($images\u dir.$file、$thumbnail\u image、$thumbs\u width、$thumbs\u height);
}
}
回声';
如果($index%$images_per_row==0){echo';}
}
回声';
}
否则{
echo“此库中没有图像。

”; } ?>
我正在使用Smoothbox,但无法使其工作。我希望我可以写一个更小的脚本,而不是使用上面链接中的脚本

我已经研究过创建一个简单的灯箱,比如这个,但我不确定如何将它与上面的代码集成

这是我希望使用的带有我的照片的网站链接:


我希望照片放大并居中,后面的所有东西都有一个半透明的背景。

通过查看您的代码,看起来您没有调用Java

当链接一个js文件时,您需要添加一个脚本元素来告诉Java一个元素正在被激活

尝试将以下内容放置在头部标签之间或缩略图div的结束标签下:

<script type="text/javascript">
$(function() {
    $('#thumbnails a').lightbox();
});
</script>

$(函数(){
$(“#缩略图a”).lightbox();
});

我使用了smooth box,代码对我来说很好

所以我必须链接javascript文件,还要添加一个调用函数的脚本?我正在试这个。是的。我建议在网站上阅读JavaScript教程