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

  • Home
  • SEARCH
  • 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 8118611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:32:34+00:00 2026-06-06T04:32:34+00:00

I have multiple divs in a wrap, they have different height. I’d like to

  • 0

I have multiple divs in a wrap, they have different height. I’d like to float left. 2 Divs can fit in a row. But since each of the div has different height, there’s pretty much odd space left in next row. Can I remove the space and move the div’s up?

Please look at the image:

Here’s code:

<div class="wrap">
    <div class="box1">Box1 with less height.</div>
    <div class="box2">Box2 with more height.</div>
    <div class="box3">Box3 with whatever height.</div>
</div>

CSS:

.wrap{
    width:410px;
    border:1px solid red;
    overflow:hidden;
}

.box1{
    width:200px;
    height:50px;
    float:left;
    border:1px solid green;
}

.box2{
    width:200px;
    height:150px;
    float:left;
    border:1px solid blue;
}

.box3{
    width:200px;
    height:250px;
    float:left;
    border:1px solid blue;
}

JSFiddle:
http://jsfiddle.net/NsH5M/

PS. The div heights are not fixed. This is just for example.
Edit: Sorry, I should have mentioned that its not possible to edit markup.

enter image description here

  • 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-06T04:32:36+00:00Added an answer on June 6, 2026 at 4:32 am

    Try to use masonry. This should help you to arrange your div without empty space.

    That’s how it is used as an example of your code: jsfiddle (Updated 11/2018)

    HTML:

    <div class="wrap">
        <div class="box box1">Box1 with less height.</div>
        <div class="box box2">Box2 with more height.</div>
        <div class="box box3">Box3 with whatever height.</div>
    </div>
    

    JavaScript:

    $(function(){
      $('.wrap').masonry({
          // options
        itemSelector : '.box'
      });
    });​
    ​
    

    And CSS:

    .wrap{
        width:410px;
        border:1px solid red;
        overflow:hidden;
    
    }
    
    .box{
        float: left;
        width: 200px;
    }
    
    .box1{
        height:50px;
        border:1px solid green;
    }
    
    .box2{
        height:150px;
        border:1px solid blue;
    }
    
    .box3{
        height:250px;
        border:1px solid blue;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple divs with a fixed width and height (think about some sort
i have a screen with multiple little widgets (all with different divs around them).
I have multiple divs, each with a unique id and image. I would like
I have have multiple divs' with similar code within it, but also has a
I have multiple divs like this: <div class=small></div> <div class=small></div> <div class=small></div> <div class=small></div>
I have multiple divs like setted up below. I want 1 (one) JQuery function
this is kinda tricky to explain,but here goes....I have multiple hidden divs that swap
I hope I can word this okay. I have multiple divs all called '.collapse-conten'
I have a page with multiple divs that hold different sections of content. Initially,
I have a page with multiple divs in it. I like to update the

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.