Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7029763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:34:52+00:00 2026-05-28T00:34:52+00:00

I am building my own image gallery, Like fancybox . See: http://snabbdesign.com/stack/stack.html I am

  • 0

I am building my own image gallery, Like fancybox.

See: http://snabbdesign.com/stack/stack.html

I am having some problem with fading out and in #gallery. Some times the background (#gallery) will fade out before the image.

Also some times the .gallery_image wont be centered as it should.

Please help!

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body{
margin:0;
}
#gallery{
width:100%;
height:100%;
position:fixed;
left:0;
top:0;
background:#000;
opacity:0.95;
display:none;
}
.gallery_image{
width:auto;
height:auto;
position:fixed;
left:0;
top:0;
}
#gallery_left,#gallery_right{
position:fixed;
height:100px;
width:100px;
top:50%;
margin-top:-50px;
background:#f00;
cursor:pointer;
display:none;
}
#gallery_left{
left:0;
}
#gallery_right{
right:0;
}
</style>
</head>
<body>
<div id="ji">
<img src="1.png">
<img src="2.png">
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
<script>
$(document).ready(function () {
   var $gallery_loaded = false,
      height_of_window = $(window).height(),
      width_of_window = $(window).width(),
      max_height = height_of_window - 100,
      max_width = width_of_window - 100,
      $ji_img = $('#ji img');
   $ji_img.css('cursor', 'pointer');
   $ji_img.click(function () {
      var position_of_image = $(this).index();
      if (!$gallery_loaded) {
         $gallery_loaded = true;
         $('body').append('<div id="gallery"></div>');
         $ji_img.each(function () {
            var big_src = $(this).attr("src").match(/[^\.]+/) + "-big.png";
            $('body').append('<img style="display:none" class="gallery_image" src="' + big_src + '" />');
         }); // end each
         $('.gallery_image').each(function () {
            var $this = $(this);
            height_of_gallery_image = $this.height();
            width_of_gallery_image = $this.width();
            if (width_of_gallery_image >= max_width) {
               $this.css({
                  'max-width': max_width + 'px'
               })
            }
            if (height_of_gallery_image >= max_height) {
               $this.css({
                  'max-height': max_height + 'px'
               })
            }
            margin_top = (height_of_window - $this.height()) / 2;
            margin_left = (width_of_window - $this.width()) / 2;
            $this.css({
               'margin-top': margin_top + 'px',
               'margin-left': margin_left + 'px'
            })
         }); // end each
         $('body').append('<div id="gallery_left"></div><div id="gallery_right"></div>');
      } //end if gallery_loaded
      $('#gallery').fadeIn(500);
      $('#gallery_left,#gallery_right').delay(1000).fadeIn(500);
      $('.gallery_image').eq(position_of_image).delay(500).fadeIn(500)
      $('#gallery').click(function () {
         $('.gallery_image').fadeOut(500)
         $('#gallery_left,#gallery_right').fadeOut(500);
         $('#gallery').delay(500).fadeOut(500);
      });
   }); // end click function
}); // end document redy
</script>
</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:34:53+00:00Added an answer on May 28, 2026 at 12:34 am

    1) this doesn’t happen for me, but if it does I would suggest you have a look at .queue()

    2) use .outerHeight() and .outerWidth() instead .height() and .width()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have for some time now being building my own calendar because the standard
I'd like some advice on building in known errors. Let's say I have a
I am building my own CRM access database that will contain a list of
I am building my own local search UI element that gives local search suggestions
I am learning a lot about design patterns when I am building my own
I am building a small device with its own CPU (AVR Mega8) that is
I am currently building a webshop for my own where I want to increment
I know RIM has their own IDE ( BlackBerry JDE ) for building BlackBerry
I'm building a public website which has its own domain name with pop/smtp mail
The background I'm building a fair-sized web application with a friend in my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.