好吧,我有一个灯箱,除1个问题以外工作得很好。这些图像是动态构建的,它获得了10个图像的列表,并循环显示每行图像。所以我可以看到发生了什么问题。无论我选择哪一张图片显示灯箱中的第一张图片,我都需要为图片路径或图片名称传递一个变量。加载动态图像名称时的灯箱问题
我真的没有那么多JavaScript的经验,但什么即时希望做的就是把$popup_item->attributes()->name
到一个变量,通过onclick
事件经过,然后里面div
与id="light"
强似$popup_item->attributes()->name
我传递变量,但不能肯定是否这是最好的办法,甚至从哪里开始
有这样它遍历并打印出的弹出容器一堆次的循环:
foreach($xml->config->popup as $popup_item){
}
和HTML
<div id="popup_container">
<!-- We use a lightbox to show the image in full size since large popups are scaled -->
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">
<!-- This is the scaled image -->
<!--popups are stored in images/popups/images/ in the following format -->
<!--id_popupname.png which we build dynamically below because -->
<!-- the popup name will always be same name as the popupimage with the user id preceeding it -->
<img src="images/popups/images/<?php echo $item_id . "_" . strtolower($popup_item->attributes()->name) . ".png" ;?>" alt="Popup Image"/>
</a>
<!--This holds the un-scaled image in the popup box which is hidden initially until you click the image-->
<div id="light" class="white_content">
<img src="images/popups/images/<?php echo $item_id . "_" . strtolower($popup_item->attributes()->name) . ".png" ;?>" alt="Popup Image"/></a>
<!--This allows you to close the lightbox window from within the lightbox window-->
<a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a>
</div>
<div id="fade" class="black_overlay"></div>
</div> <!--end of popup container-->
而如果灯箱CSS它可以帮助:
.black_overlay{
display: none;
position: fixed;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
z-index:1001;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=60);
}
.white_content {
display: none;
position: fixed;
top: 25%;
left: 25%;
width: 50%;
height: 50%;
padding: 16px;
border: 16px solid orange;
background-color: white;
z-index:1002;
overflow: auto;
}
编辑:其实我需要通过2个变量中,$item_id
和$popup_item->attributes()->name
,但概念是相同的
你有一个额外的(*不打开。*)的第二'img'标签后'' .. –