2012-10-26 16 views
6

Mam problemy z ustawieniem colorbox przy użyciu tylko dostępnej rzutni. Jak tylko ustawię atrybut maxHeight lub maxWidth, żadne obrazy nie będą wyświetlane. Kolorbox otwiera się, ale pozostaje na "kołowrotku".Colorbox maxWidth, maxHeight nie działa

function showImage(e) { 
    $.colorbox({href:$(e.currentTarget).attr("src")}); } 

jQuery(document).ready(function() { 
    $('.popout').on("click", showImage); 
    $('.popout').colorbox({rel:'popout', maxWidth:'95%', maxHeight:'95%'}); }); 

<img class="popout" src="my.jpg" alt="" width="500" height="373" /> 

Co jest nie tak z moim kodem? Czy muszę również ustawić inne atrybuty, aby uzyskać działanie maxWidth/height?

Odpowiedz

14

Wygląda na to, że przyczyną błędu JS (sprawdź konsolę programistyczną przeglądarki).

Jednak twoje podejście ma problemy. Spróbuj zamiast tego:

jQuery(document).ready(function() { 
    $('.popout').colorbox({rel:'popout', maxWidth:'95%', maxHeight:'95%', href:function(){ 
     return this.src; 
    }}); 
}); 

<img class="popout" src="my.jpg" alt="" width="500" height="373" /> 
Powiązane problemy