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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:18:06+00:00 2026-06-02T22:18:06+00:00

I have two wrapper divs side by side. I want to line up divs

  • 0

I have two wrapper divs side by side. I want to line up divs in the right column to match the position of select divs in the left column.

In the fiddle, each div in the right column should be lined up with the top of every second div in the left column. There should be one div [x] per two divs on the left.

It’s all dynamically created which is why I’ve made the fiddle the way it is http://jsfiddle.net/sKZXJ/

HTML:

<!-- Extra height added because that seems part of the problem -->
<div style="height:60px;"></div>

<div id="scroller">
    <div id="wrapper1"></div>
    <div id="wrapper2"></div>
</div>

CSS:

#scroller {
    height:300px;
    width:60px;
    overflow-x:scroll;
}
#wrapper1 {float:left; width:15px;}
#wrapper2 {float:left; width:15px;}
.littleOne {
    margin-top:1px;
    position:relative;
    height:40px;
    background-color:#006600;
}
.littleTwo {
    margin-top:1px;
    position:relative;
    background-color:#00CCCC;
}

THE FUN PART:

$(document).ready(function() {

    // Fill wrapper1 with divs
    for(var i=0;i<50;i++) {
        $('#wrapper1').append('<div id="a'+i+'" class="littleOne"></div>');
    }

    // Add selected divs to wrapper2 in matching positions
    var pos = 0;
    for(var i=0;i<50;i+=2) {
        $('#wrapper2').append('<div id="b'+i+'" class="littleTwo">X</div>');
        pos = $('#a'+i).position().top - $('#scroller').position().top;
        $('#b'+i).css('top', pos+'px');
    }

});
  • 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-02T22:18:11+00:00Added an answer on June 2, 2026 at 10:18 pm

    Here you go: http://jsfiddle.net/f5ArU/3/

    $(document).ready(function() {
    
        // Fill wrapper1 with divs
        for(var i=0;i<50;i++) {
            $('#wrapper1').append('<div id="a'+i+'" class="littleOne"></div>');
        }
    
        // Add selected divs to wrapper2 in matching positions
        var pos = 0;
        var offset = 0;
        for(var i=0;i<50;i+=2) {
            var b = $('<div id="b'+i+'" class="littleTwo">X</div>');
            $('#wrapper2').append(b);
            pos = $('#a'+i).position().top - offset;
            offset += b.height() + 1;
            b.css('top', pos+'px');
        }
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two div's (side by side) inside a parent div, i want right
I have two inner divs which are nested inside a wrapper div. I want
I have two divs inside a div, I want them both adjacent to each
In my site, I have two divs - right and left. Both are contained
I have a div (#wrapper) containing 2 divs standing side by side. I would
I have two divs and a wrapper div around them. The wrapper div is
I have a set of divs eg: <div class=wrapper> <div class=uct_attr data-tags=one two three
I have two divs inside a wrapper div of width 880px. The first div
I have two div's and I want to show them next to each other.
I have two classes in my REST API wrapeer: Wrapper::Folder and Wrapper::File . Each

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.