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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:30:07+00:00 2026-05-27T00:30:07+00:00

It is easy to arrange DIVs horizontally with float. For example: <div style="width: 500px;">

  • 0

It is easy to arrange DIVs horizontally with float. For example:

<div style="width: 500px;">
 <div style="float:left; width: 200px; height: 100px; background-color:Yellow;"></div>
 <div style="float:left; width: 150px; height: 60px; background-color:Blue;"></div>
 <div style="float:left; width: 140px; height: 240px; background-color:Green;"></div>
 <div style="float:left; width: 180px; height: 200px; background-color:Red;"></div>
 <div style="float:left; width: 130px; height: 160px; background-color:Purple;"></div>
</div>

This will produce:
enter image description here

But how to arrange the DIVs both horizontally and vertically? In this case, how to shift the Red and Purple DIVs upper where there is empty space (under Yellow and Blue DIVs)?

NOTE: This is just an example, and I wish to find a method to make the arrangement for any set of DIVs (not only this typical example).

  • 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-27T00:30:07+00:00Added an answer on May 27, 2026 at 12:30 am

    Assuming you are working with a dynamic set of arbitrarily sized objects, there is no pure CSS method to achieve this. You can get close by using a CSS3 multi-column layout if:

    1. You only need to support modern browsers.
    2. All objects can be arranged into equal-height groups.

    Here, objects are arranged in groups of 300px height.

    <div id="blocks">
      <div style="height: 100px; background-color: yellow;"></div>
      <div style="height: 200px; background-color: blue;"></div>
      <div style="height: 300px; background-color: green;"></div>
      <div style="height: 200px; background-color: red;"></div>
      <div style="height: 160px; background-color: purple;"></div>
    </div>
    
    #blocks {
      -moz-column-count: 3;
      -moz-column-gap: 0;
      -webkit-column-count: 3;
      -webkit-column-gap: 0;
      column-count: 3;
      column-gap: 0;
      width: 450px;
    }
    #blocks div {
      width: 150px;
    }
    

    http://jsfiddle.net/RTLun/

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

Sidebar

Related Questions

Easy question, it is valid to have overlapping spans in html? Example: <span id=1>This
Single inheritance is easy to implement. For example, in C, the inheritance can be
Easy enough to make a div with a background image clickable: $(.socialMedia).click(function(){ window.location=$(this).find(a).attr(href); return
Simple easy one. I am trying to rotate image inside divs and cycle back
Does anyone know of any tools or easy methods to help re-arrange and organise
Easy one to explain. Is there any way I can do this: <div id=header
Easy question this time. I'm trying to test whether or not a string does
Another easy one hopefully. Let's say I have a collection like this: List<DateTime> allDates;
An easy jQuery question. I have several identical forms ( except their name )
How easy would it be to write a dumb LINQ provider that can just

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.