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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:36:41+00:00 2026-05-24T04:36:41+00:00

I have a fluid width container DIV. Within this I have 4 DIVs all

  • 0

I have a fluid width container DIV.

Within this I have 4 DIVs all 300px x 250px…

<div id="container">
   <div class="box1"> </div>
   <div class="box2"> </div>
   <div class="box3"> </div>
   <div class="box4"> </div>
</div>

What I want to happen is box 1 to be floated left, box 4 to be floated right and box 2 and 3 to be spaced evenly between them. I want the spacing to be fluid as well so as the browser is made smaller the space becomes smaller also.

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-05-24T04:36:43+00:00Added an answer on May 24, 2026 at 4:36 am

    See: http://jsfiddle.net/thirtydot/EDp8R/

    • This works in IE6+ and all modern browsers!
    • I’ve halved your requested dimensions just to make it easier to work with.
    • text-align: justify combined with .stretch is what’s handling the positioning.
    • display:inline-block; *display:inline; zoom:1 fixes inline-block for IE6/7, see here.
    • font-size: 0; line-height: 0 fixes a minor issue in IE6.
    #container {
      border: 2px dashed #444;
      height: 125px;
      text-align: justify;
      -ms-text-justify: distribute-all-lines;
      text-justify: distribute-all-lines;
      /* just for demo */
      min-width: 612px;
    }
    
    .box1,
    .box2,
    .box3,
    .box4 {
      width: 150px;
      height: 125px;
      vertical-align: top;
      display: inline-block;
      *display: inline;
      zoom: 1
    }
    
    .stretch {
      width: 100%;
      display: inline-block;
      font-size: 0;
      line-height: 0
    }
    
    .box1,
    .box3 {
      background: #ccc
    }
    
    .box2,
    .box4 {
      background: #0ff
    }
    <div id="container">
      <div class="box1"></div>
      <div class="box2"></div>
      <div class="box3"></div>
      <div class="box4"></div>
      <span class="stretch"></span>
    </div>

    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/EDp8R/3/

    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 class="box3"></div>
        <div class="box4"></div>
    </div>
    

    And this does:

    <div id="container">
        ..
        <div class="box3"></div>
        <div class="box4"></div></div>
    

    You can use this for any arbitrary number of child divs without adding a boxN class to each one by changing

    .box1, .box2, .box3, .box4 { ...
    

    to

    #container > div { ...
    

    This selects any div that is the first child of the #container div, and no others below it. To generalize the background colors, you can use the CSS3 nth-order selector, although it’s only supported in IE9+ and other modern browsers:

    .box1, .box3 { ...
    

    becomes:

    #container > div:nth-child(odd) { ...
    

    See here for a jsfiddle example.

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

Sidebar

Related Questions

I have nested divs like this (pseudo code..) <div0> <div1></div1> <div2>fluid width</div2> <div3></div3> </div0>
I have a fluid-width div with rounded corners using the border-radius, as well as
I have a fluid page (100% width) with this inside: [image-fixed-width] | [text-fluid-width -----------------------------------]
I have two div's without any width as I am working on a fluid
This is the example I have: Line height does not apply to fluid divs.
How can I set spacing between divs to auto inside fluid width parent div?
I have a div which has a fluid width, thus I cannot predict its
I have two divs as follows: fluid width content fixed width content I'm trying
I have a fluid width theme and I am using jQuery Masonry and Infinite
I have a webpage with a fluid layout with a 100% width. When 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.