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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:55:19+00:00 2026-05-14T08:55:19+00:00

so i have 4 divs (i actually have many more but this will simplify

  • 0

so i have 4 divs (i actually have many more but this will simplify the question). i want to display them in two columns. the 4 divs vary in height. the number of actual divs in the end will vary.
so if i have this

<div id="1" style="height: 200px" class="inline">some content here</div>
<div id="2" style="height: 600px" class="inline">some content here</div>
<div id="3" style="height: 300px" class="inline">some content here</div>
<div id="4" style="height: 200px" class="inline">some content here</div>

with styling thus

.inline { display: inline-block; vertical-align: top; width: 48%;}

so #1 would go left and then #2 would shove up beside it to the right, great, but the #3 will not slide up the 400px to fit nicely below #1. (of course)… it goes on the left side but at 600px from the top clearing the bottom of #2. etc…

how would i get the divs to slide up into the empty spaces, is it possible with css? jquery maybe?
i know i could write column divs to mark it up, but since the number of divs constantly change and the heights vary according to content. It would be nice to just get rid of the space since we dont really care about the order.

any thoughts?

  • 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-14T08:55:19+00:00Added an answer on May 14, 2026 at 8:55 am

    Unfortunately this is impossible with pure CSS, you are going to need separate divs for each column. Fortunately, you can achieve this using jQuery. Something like this should do the trick:

    $(function() {
        var odd_divs = $('div.inline:odd');
        var even_divs = $('div.inline:even');
        var left = $('<div id="left-column" class="column"/>').append(odd_divs);
        var right = $('<div id="right-column" class="column" />').append(even_divs);
        $('#somewhere').append(left).append(right);
    });
    

    And change your CSS to this:

    .column {
        width: 50%;
        display: inline-block; 
        vertical-align: top;
    }
    

    EDIT

    As Brian McKenna noted, it is actually possible to achieve this effect using CSS floats. You can use jQuery to add the classnames as so:

    $(function() {
        $('div.inline:odd').addClass('box-left');
        $('div.inline:even').addClass('box-right');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't know how to ask this without a picture. I have two divs,
I have three DIVs, something like this: <div id=header> ... </div> <div id=content> <div
I have two divs and two separate links that triggers slideDown and slideUp for
i have the following jquery code. basically i will have several overlapped divs and
I have a set of divs that I want to make collapsible/expandable using jQuery's
I have two divs that are floating next to each other. What i would
I have 3 divs and I want to replace the first div with an
This is probably a very common question, but I was unable to find an
I have three divs : <div id=login /> <div id=content /> <div id=menu />
I have three divs: A, B and C. A is currently visible and I

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.