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 8883249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:46:10+00:00 2026-06-14T20:46:10+00:00

I’m trying to create a gallery, but being totally new to jQuery I’m in

  • 0

I’m trying to create a gallery, but being totally new to jQuery I’m in a kind of deadlock.

I want to create a gallery consisting of several small pictures that expand to full width on click and return to its original on another. At the same time I want all the rest divs in parent wrap to hide while clicked image expands. All that must be running smoothly and prettily. That’s what I can’t reach.
All pics have .image class and each of them has class .one .two and so on. They are all under parent wrap.

$(".image").bind('click', function() {
     $(this).animate({width: "100%", height: "100%"}, 800);
$(".image").not(this).hide("slow");
});

$('.image').toggle(function(){
    $(this).animate({width: "100%", height: "100%"}, 800);    
}, function(){
    $(this).animate({width: "90px", height: "90px"}, 800);
    $(".image").not(this).show("slow");
});

The result of my efforts by now http://jsfiddle.net/baltar/TRuNv/4/

Good example of smoothness here http://css-tricks.com/examples/InfoGrid/

Also, it would be great to set up adjusting the height of parent div on the fly, so image of any proportions will fit. I’ve tried to set parent’s height to auto, but that didn’t work.

I realize that my question is to big to ask, but maybe at least anyone could advise which direction should I look to.

Thanks in advance!

  • 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-06-14T20:46:11+00:00Added an answer on June 14, 2026 at 8:46 pm

    The following jQuery does most of what you request:

    $(".image").bind('click', function() {
        var that = $(this), // caching the current element
            offsets = that.position(), // edited to use position() instead of offset()
            top = offsets.top,
            left = offsets.left,
            clone = that.clone(),
            parent = that.parent(), // caching the parent element
            width = parent.width(),
            height = parent.height();
    
        // adding the 'clone' element to the parent, and adding the 'clone' class-name    
        clone.addClass('clone').appendTo(parent).css({
            // positioning the element at the same coordinates
            // as the current $(this) element
            'top': top,
            'left': left
        }).animate({
            // animating to the top-left corner of the parent, and
            // to the parent's dimensions
            'top': 0,
            'left': 0,
            'width': width,
            'height': height
        }, 1000).click( // binding a click-handler to remove the element
    
        function() {
            // also fading the sibling elements back to full opacity
            $(this).fadeOut().siblings().animate({
                'opacity': 1
            }, 1000);
        }).siblings().animate({
            // fading-out the sibling elements
            'opacity': 0.1
        }, 1000);
    
    });​
    

    This requires the CSS:

    .wrap {
        /* your other unchanged CSS, and: */
        position: relative;
    }
    .clone {
        position: absolute;
    }
    

    JS Fiddle demo.

    References:

    • addClass().
    • animate().
    • click().
    • clone().
    • fadeOut().
    • height().
    • offset().
    • parent().
    • position().
    • siblings().
    • width().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a jQuery Gallery that lets the user flip (with
I am trying to create a jQuery image gallery(I rather create one, than use
I am trying to create a thumbnail gallery using XML databinding. But the data
I'm trying to use the following to create a small thumbnail gallery: This is
I'm currently trying to create a gallery of pictures loaded from Internet. I'm using
I'm trying to create a wallpaper sharing gallery, and i want my visitors to
I'm trying to create a new picture record within my gallery. Users can create
Hi I'm trying to create a gallery using JavaScript. I want to have a
I'm trying to create some kind of gallery view for my game's level select
I am trying to create a gallery through a plugin I am making but

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.