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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:55:11+00:00 2026-05-25T05:55:11+00:00

UPDATE: The parent div (#container) must have a fixed height. I jsut want to

  • 0

UPDATE:

The parent div (#container) must have a fixed height. I jsut want to shift the content in it so the active div is at the top and all overflow is hidden.


I am working on a webpage where a parent div has a fix size and will have several child divs in it. Each of these child divs will have an anchor tag that is always visible and it’s own child div that will only be shown when it’s sibling anchor tag is clicked.

I have this much working but I am running into the issue that when the sibling div is shown it sometimes goes out of the parent div and it’s content is hidden. I would like to have the contents of this div repositioned to the top of the parent div so that it’s content is never hidden. How would I accomplish this using jQuery?

You can see what I’m talking about by clicking Item2 in this Fiddle: http://jsfiddle.net/Broham/LA22t/1/

Html:

<div id="container">
    <div class="item">
        <a href="#">Item1</a>
        <div class="desc">A bunch of stuff about item 1!</div>
    </div>
    <div class="item">
        <a href="#">Item2</a>
        <div class="desc">
            A bunch of stuff about item 2!<br/>More stuff for item 2!<br/>last item 2 thing
        </div>
    </div>
    <div class="item">
        <a href="#">Item3</a>
        <div class="desc">
            A bunch of stuff about item 3!<br/>More stuff for item 3
        </div>
    </div>
</div>

css:

.desc
{
 display:none;   

}

#container
{
    height:75px;
    overflow:hidden;
    border-style:solid;
    border-width:1px;
}

jQuery:

$(".item a").click(function () {
    $(this).siblings(".desc").animate({ height: 'toggle' });
            });

What I have tried so far:

http://jsfiddle.net/Broham/LA22t/3/

But this only moves the active div, what I need to do is shift all of the content up and hide the overflow…

  • 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-25T05:55:11+00:00Added an answer on May 25, 2026 at 5:55 am

    You have two options.

    You can either hid all of the div above it (thus making it appear at the top), or you can float the div over the top of the other elements, which sounds more like what you want. However, floating it to the top is difficult, and requires different methods in different browsers, so the easiest way for you is just to set all the other items to display:none, and then display:block again when you click to close the one you are viewing.

    Here, this does what you want:

    $(".item a").click(function () {
        if(!this.opvar)this.opvar=false;
        $(this).siblings(".desc").animate({ height: 'toggle' });
        if(!this.opvar)$(this).parent().siblings(".item").css('display','none');
        else $(this).parent().siblings(".item").css('display','block');
        this.opvar = !this.opvar;
            });
    

    Just a crude example though, there are better ways to do it.

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

Sidebar

Related Questions

I have statement $(#myDiv).attr(disabled,disabled); I thought that once I disable parent container, all elements
Is there a way to have a child DIV within a parent container DIV
Is there a way to update information in a div of a parent page
I basically have a layout like this: <body> <div style=height: 150px; width: 200px; background:
I have the following HTML snippet: Block 1: <div style="position: absolute; top: 105px; left:
I have a a parent div that spans the width of the browser with
I need a fixed position thead that is static when the parent DIV element
Is there a way to update only the parent UpdatePanel without updating the child
I'm trying to update an image in a parent window with clickable links in
any better way to write this ? $(this).parent().parent().find( dd ul).toggle(); update.. I am trying

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.