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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:06:53+00:00 2026-05-19T03:06:53+00:00

Thanks in advance for any-help with this, I’ll try and explain it well. I

  • 0

Thanks in advance for any-help with this, I’ll try and explain it well.

I have a container of 1000px width and 220px height, in this I will have three columns 220px in height but with different widths (77px, 200px and 300px). When you click one div it will open to a fixed size (the same for each, say 400px) and the others which are not clicked will shrink back to their original sizes (77px, 200px and 300px). Like an accordian with different widths..

My jquery is getting there but not quite, I know how to create an Event on click, I know from there I need to shrink everything but the one I clicked back to their orignal size. I finish but making the one clicked expand to the size it needs to be.

jsfiddle here!

    $(document).ready(function(){
 // Your code here
 $('.section').click(function() {
  $('.section').not(this).animate({width:"77px"},400);
  //alert('clicked!');
  $(this).animate({width:"400px"},400);
 });
});

<div id="pictureNavContainer">

 <div class="section pictureSectionOne" id="1"></div>
 <div class="section pictureSectionTwo" id="2"></div>
 <div class="section pictureSectionThree" id="3"></div>

</div>

<style>
#pictureNavContainer{background-color:#262626; width:1000px; height:220px; overflow:hidden;}
.pictureSectionOne{float:left; background:yellow; height:220px; width:77px;}
.pictureSectionTwo{float:left; background:red; height:220px; width:177px;}
.pictureSectionThree{float:left; background:blue; height:220px; width:400px;}
</style>

I figured a kind of solution:

<script>
$(document).ready(function(){
    // Your code here
    $('.section').click(function() {



        $('#1').animate({width:"50px"},400);
        $('#2').animate({width:"100px"},400);
        $('#3').animate({width:"200px"},400);

        //alert('clicked!');
        $(this).animate({width:"400px"},400);
    });
});
</script>

But the code isnt very good.. but it works

This:

$(function(){

    var $sections = $('.section');
    var orgWidth = [];

    var animate = function() {
        var $this = $(this);
        $sections.not($this).each(function(){
            var $section = $(this),
                org = orgWidth[$section.index()];
            $section.animate({
                width: org
            }, 400);
        });
        $this.animate({
            width: 400
        }, 400);
    };

    $sections.each(function(){
        var $this = $(this);
        orgWidth.push($this.width());
        $this.click(animate);  
    });
});
  • 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-19T03:06:54+00:00Added an answer on May 19, 2026 at 3:06 am

    Ok, I think I got it to work. Like this?

    However, this doesn’t set the clicked element to a fixed size but to the size that is left. If you resize the clicked element to a fixed size the three columns will either become wider or thinner then 1000px, is that really what you want?

    Here is an updated example. This does exactly what you asked for, but I’m not sure that this is what you want.

    Code with inline comments:

    $(function(){
        // we cache the result set from the selector so we can
        // reuse them without having to query the DOM again
        var $sections = $('.section');
    
        // placeholder array for original widths
        var orgWidth = [];
    
        // handler function to take care of the animations
        var animate = function() {
            var $this = $(this);
            // iterate through all but current element
            $sections.not($this).each(function(){
                // create jQuery object and fetch original width
                var $section = $(this),
                    org = orgWidth[$section.index()];
                // animate current element
                $section.animate({
                    width: org
                }, 400);
            });
            // animate current element
            $this.animate({
                width: 400
            }, 400);
        };
    
        // let's iterate through each of the elements
        $sections.each(function(){
            // create jQuery object for current element
            var $this = $(this);
            // push the elements width into the placeholder
            orgWidth.push($this.width());
            // bind the handler to the click event
            $this.click(animate);  
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem, thanks in advance for any help regarding this issue.
Thanks in advance for any help you can provide on this issue! I manage
Thanks for any help in advance, I can't wrap my SQL skills around this
I am using c# .net. Thanks in advance for any help. I have searched
Thanks in advance for any help. I have a sliding div with jquery .animate,
i have very serious problem if any tech expert can help...thank you in advance..
Thanks in advance for your help. I have a need within an application to
thanks in advance for any help I am trying to figure out how to
Hey guys, thanks in advance for any help or input. I am having trouble
Thanks in advance for any help. I've got two combo boxes which I'd like

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.