0

I am using lightbox to show an image in php.

My current code:

<a class="sri" href="administrator/all_photo/mywork/
<?php 
    echo $res['path'];
?>
_1.jpg" rel="lightbox">
<img src="administrator/all_photo/mywork/
<?php 
    echo $res['path'];
?>
_1.jpg" class="photo_frame photo_size" >
<br />
<?php 
    echo $res['title'];
?>
</a>

CSS and JS for lightbox have already been included. In the above code, $res['title'] and $res['path'] are being fetched from database.

If I click on the image or the text which is showing as $res['title'], lightbox effect is showing. The image is within the lightbox. Now I need the $res['title'] value also be displayed when the lightbox is opened along with the image.

How do I do that?

4

3 回答 3

1

您必须添加标题:

<a class="sri" href="administrator/all_photo/mywork/
<?php 
    echo $res['path'];
?>
_1.jpg" rel="lightbox">
<img src="administrator/all_photo/mywork/
<?php 
    echo $res['path'];
?>
_1.jpg" title="
<?php 
    echo $res['title'];
?>
" class="photo_frame photo_size" >
</a>
于 2012-12-03T20:26:09.003 回答
1

只需使用标签中的title参数,如灯箱文档中所述:<a>

可选:如果要显示标题,请使用 title 属性。

于 2012-12-03T20:11:52.563 回答
0

您应该能够将所有标记移动到 div 中。将 rel="lightbox" 添加到该 div,它应该可以工作。虽然这取决于您使用的灯箱库。

于 2012-12-03T20:09:52.397 回答