Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [AJAX]Popup w Jquery
northwest
post
Post #1





Grupa: Zarejestrowani
Postów: 788
Pomógł: 1
Dołączył: 17.09.2004

Ostrzeżenie: (10%)
X----


Witam serdecznie,
Kombinuję nad popupem wyskakującym w momencie wczytania strony (to mi działa nawet) - ale mam problem z wycentrowaniem go:(

Mam jquery 1.7.2 i taki kod:
  1. var id = '#dialog';
  2. //Get the screen height and width
  3. var maskHeight = jQuery(document).height();
  4. var maskWidth = jQuery(window).width();
  5.  
  6. //Set heigth and width to mask to fill up the whole screen
  7. jQuery('#mask').css({'width':maskWidth,'height':maskHeight});
  8.  
  9. //transition effect
  10. jQuery('#mask').fadeIn(1000);
  11. jQuery('#mask').fadeTo("slow",0.8);
  12.  
  13. //Get the window height and width
  14. var winH = jQuery(window).height();
  15. var winW = jQuery(window).width();
  16.  
  17. //Set the popup window to center
  18. //jQuery(id).css('top', winH/2-$(id).height()/2);
  19. //jQuery(id).css('left', winW/2-$(id).width()/2);
  20. //transition effect
  21. jQuery(id).fadeIn(2000);
  22.  
  23. //if close button is clicked
  24. jQuery('.window .close').click(function (e) {
  25. //Cancel the link behavior
  26. e.preventDefault();
  27.  
  28. jQuery('#mask').hide();
  29. jQuery('.window').hide();
  30. });
  31.  
  32. //if mask is clicked
  33. jQuery('#mask').click(function () {
  34. jQuery(this).hide();
  35. jQuery('.window').hide();
  36. });


Ten parametr od centrowania nie chce mi działać:
jQuery(id).css('top', winH/2-$(id).height()/2);
jQuery(id).css('left', winW/2-$(id).width()/2);

Wiecie może dlaczego?

Northwest

mam taki css:
  1. #mask {
  2. position:absolute;
  3. left:0;
  4. top:0;
  5. z-index:9000;
  6. background-color:#000;
  7. display:none;
  8. }
  9. #boxes .window {
  10. position:absolute;
  11. left:0;
  12. top:0;
  13. width:440px;
  14. height:200px;
  15. display:none;
  16. z-index:9999;
  17. padding:20px;
  18. }
  19. #boxes #dialog {
  20. width:375px;
  21. height:203px;
  22. padding:10px;
  23. background-color:#ffffff;
  24. }
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 17.09.2025 - 20:49