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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:16:13+00:00 2026-05-24T14:16:13+00:00

I have DIV with flexible width set e.g. min-width:800px and max-width:1400px. In this DIV,

  • 0

I have DIV with flexible width set e.g. min-width:800px and max-width:1400px. In this DIV, there are many boxes with fix width 200px and display:inline-block. So depending on parent DIV width, these boxes fill the entire space.

My problem is the blank space on the right side which is caused by variable width of the parent div. Sometimes this blank space is small and looks fine, but with different widths of the parent div, this blank space is almost 200px.

I don’t know, if I described my problem in enough detail, I hope this picture will help to describe my actual situation:

enter image description here

And this is what I would like to have:

enter image description here

This auto-margin could be easily achieved by using TABLE. However, I don’t know the exact number of columns, since it depends on user’s screen resolution. So I can’t use table and rather stick with CSS.

Anyone has an idea how to solve this ? Thank you in advance for your comments and answers.

EDIT: I don’t need support of IE6. I would like to support IE7, but IE7 is optional as I know there are limitations so I will probably use fixed width of “div.wrapper” in IE7

EDIT2 I need to handle multiple rows of these boxes, so they don’t exceed the “div.wrapper” box and wrap correctly in multiple lines of boxes, not just in one long line.

EDIT3 I don’t know the number of “columns” as this is very variable depending on user’s screen resolution. So on big screen there could be 7 boxes in one row, and on small screens there could be just 4 boxes in one row. So I need solution that doesn’t set fixed number of boxes in one row. Instead, when the boxes don’t fit in one row, they should just wrap to a next row.

  • 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-24T14:16:13+00:00Added an answer on May 24, 2026 at 2:16 pm

    This is as close as IE7-compatible CSS can get: http://jsfiddle.net/thirtydot/79mFr/

    If this still isn’t right, it’s time to look at using JavaScript and hopefully also jQuery. If you define your requirements properly, it should be trivial to get this perfect with JavaScript.

    HTML:

    <div id="container">
        <div></div>
        <div></div>
        ..
        <span class="stretch"></span>
    </div>
    

    CSS:

    #container {
        border: 2px dashed #444;
    
        text-align: justify;
        -ms-text-justify: distribute-all-lines;
        text-justify: distribute-all-lines;
    
        min-width: 800px;
        max-width: 1400px
    }
    
    #container > div {
        margin-top: 16px;
        border: 1px dashed #f0f;
        width: 200px;
        height: 200px;
        vertical-align: top;
        display: inline-block;
        *display: inline;
        zoom: 1
    }
    .stretch {
        width: 100%;
        display: inline-block;
        font-size: 0;
        line-height: 0
    }
    

    The extra span (.stretch) can be replaced with :after.

    This still works in all the same browsers as the above solution. :after doesn’t work in IE6/7, but they’re using distribute-all-lines anyway, so it doesn’t matter.

    See: http://jsfiddle.net/thirtydot/79mFr/2/

    There’s a minor downside to :after: to make the last row work perfectly in Safari, you have to be careful with the whitespace in the HTML.

    Specifically, this doesn’t work:

    <div id="container">
        <div></div>
        <div></div>
    </div>
    

    And this does:

    <div id="container">
        <div></div>
        <div></div></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a div with a set height of 200, and sometimes there's enough
I have a div tag styled through CSS. I set the padding to 10px
I have div containing a list of flash objects. The list is long so
I have a div and an iframe on the page the div has z-index:
I have a div in which a page is loaded with the DojoX Layout
I have a div with overflow:hidden , inside which I show a phone number
I have a div with a <h1> tag in a div, with no margins.
I have a div container and have defined its style as follows: div#tbl-container {
I have a div with two nested divs inside, the (float:left) one is the
I have a Div with five float divs inside: var div=document.createElement(div); div.className=cssDivNino; var divFolio=document.createElement(div);

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.