好吧,我有一個燈箱,除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'標籤後'' .. –