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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:47:16+00:00 2026-06-13T11:47:16+00:00

Please take a look at this fiddle: http://jsfiddle.net/dhcyA/ Try clicking on a block. What

  • 0

Please take a look at this fiddle: http://jsfiddle.net/dhcyA/

Try clicking on a block. What I want is that when the other elements disapear, the selected block will animate/ease to his giving position instead of just jumping like it does now. Then the same animation repeats itself when clicking again on the box, but then back to place.

Maybe to keep in mind:
I’m using a reponsive design, which means those blocks can be vertical and horizontal after scaling the window.

Any redevisions on the fiddle or suggustions would be great!

  • 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-13T11:47:17+00:00Added an answer on June 13, 2026 at 11:47 am

    Here is my solution.

    On your existing markup, I added a wrapper division to calculate the position of boxes inside the wrapper. Like this

    <div id="wrapper">
        <div class="block">
            <h2>I'm block 1</h2>
        </div>
        ....
    </div>
    

    To maintain the fluidness of the block, I created a function to position the block on the wrapper. Here is the function for position of the blocks:

    var reposition = function() {
        wrapper = $("#wrapper");
        console.log(wrapper.innerWidth());
        pLeft = 0;
        pTop = 0;
        maxRowHeight = 0;
        $(".block").each(function(){
            if($(this).data('active')) {
                $(this).data('top', pTop);
                $(this).data('left', pLeft);
            } else {
                $(this).stop(0,0).animate({
                  'top' : pTop + 'px',
                  'left' : pLeft + 'px'
                });
            }
                pLeft += $(this).outerWidth() + parseInt($(this).css('marginLeft'));
                if($(this).height() > maxRowHeight) maxRowHeight = $(this).outerHeight() + parseInt($(this).css('marginTop')); //Find out the longest block on the row
    
                if(pLeft + $(this).next().outerWidth() + parseInt($(this).next().css('marginLeft')) >= wrapper.innerWidth()) {
                   pLeft = 0;
                   pTop += maxRowHeight;
                   maxRowHeight = 0;
                }
    
        });    
    };
    

    Finally, the script to toggle the block

    $(".block").click(function() {
    
        $(this).siblings().slideToggle('slow'); //Toggle other blocks
    
        if(!$(this).data('active')){ //if the block is not active
            $(this).data('left', $(this).position().left); //sets its left
            $(this).data('top', $(this).position().top);   // and top position
            $(this).animate({ //animate at the top and bottom
                top:0,
                left:0
            },'slow');
    
            $(this).data('active',true);
    
        }else{
    
            $(this).animate({ //animate to its last known position
                top:$(this).data('top'),
                left:$(this).data('left')
            },'slow');
    
            $(this).data('active',false);
        }
    });
    

    Demos

    • Demo[Full] (Resize this to see the fluidness maintained)
    • Demo[Full] (version showing variable heights)

    Here is what this solutions gives:

    • Remembers the last position and gradually animate to/from this position
    • Block positions are calculated and animated on load and every resize
    • Repositioning happens on $(window).resize() thus maintaining the fluid nature of the block, despite the use of position absolute
    • Support variable heights
    • Minor change on existing markup & CSS

    Also fixed two issues extended by Gaby

    • Accounts for each block margin independently
    • Recalculates the position of the element after resize
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi please take a look at this fiddle http://jsfiddle.net/bloodygeese/pwjNQ/1/ I am trying to figure
Please take a look at this fiddle: http://jsfiddle.net/KA85s/3/ JQ-UI sets first option as default.
Please take a look at this example. http://jsfiddle.net/LdeWK/2/ I want to know how to
Please take a look at this fiddle http://jsfiddle.net/Qstuw/7/ First answer is selected by default,
Possible Duplicate: .prop() vs .attr() Please take a look at this fiddle: http://jsfiddle.net/DGzvP/ $(#test).prop({
Please take a look at this fiddle: http://jsfiddle.net/d3uc9/4/ I have a problem with this,
Please take a look at this fiddle: http://jsfiddle.net/hughbe/QYGcq/ As you can see, the label
please take a look at this fiddle : http://jsfiddle.net/cX47v/1 I am simply trying to
could somebody please take a look at this http://jsfiddle.net/bloodygeese/EzkFR/1/ My aim is to on
can someone take a look at this please http://jsfiddle.net/bloodygeese/ecscY/56/ it looks like I have

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.