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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:54:33+00:00 2026-06-01T16:54:33+00:00

I currently have a simple setup: a centered container div that is 90% width

  • 0

I currently have a simple setup: a centered container div that is 90% width of the screen that contains five 20% width divs. This works great when the div’s all fit on on row. They all adjust so that they are evenly spaced and centered. However, because the 5 divs must have a minimum width when the user resizes the screen to a small width they fill up more than one row and are no longer centered. Once this happens I want them to keep their minimum width, but be centered so that you can see the blue container div on either side of the top row of divs instead of having them all left aligned (and like wise for the following rows). How can I go about doing this in HTML and CSS? Thanks.

<style type="text/css">
.container {
  height: 220px;
  width: 90%;
  max-width: 1200px;

  margin-left: auto;   
  margin-right: auto;

  background-color: blue;
}

.box {
  position: relative;
  height: 100%;
  width: 20%;
  min-width: 200px;

  margin: 0 auto;
  float: left;

  background-color: red;
}
</style>


<div class="container">
    <div class="box">1</div>
    <div class="box">2</div>
    <div class="box">3</div>
    <div class="box">4</div>
    <div class="box">5</div>
</div> 
  • 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-01T16:54:34+00:00Added an answer on June 1, 2026 at 4:54 pm

    If instead of using Floats, you use display:inline-block in conjunction with text-align:center I think you will get a centered effect you desire.

    .container 
    {
        text-align:center;
    }
    
    .box 
    {
        display:inline-block;
        /*For IE*/
        *display: inline;
        zoom:1;
        /*Aligns divs vertically along the top*/
        vertical-align:top;
    }
    

    Example Here:

    http://jsfiddle.net/DigitalBiscuits/pXGz3/3/

    (Resize the result window to see the effect)

    Note: when using inline-block, make sure there are no carriage returns between the <div>s. otherwise you will get a little bit of unwanted space between them

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

Sidebar

Related Questions

Currently I have this setup in our simple-hosts.conf: url.rewrite-once = ( .*.(js|ico|gif|jpg|png|css|php|htm)(?.*)?$ => $0,
I currently have a simple form that when you click the save button will
Currently I have a simple knockoutJS object, with a few observables. But this object
Currently I have a simple maven project that is building a jar file and
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple
I have a simple gallery style link setup using image swap on hover that
I have a simple listview and listadapter setup as follows: listAdapter = new ArrayAdapter<MyDomainObject>(this,
Currently I have a simple setup where I maintain a list of bools corresponding
Simple question. Currently, for Post model, this is my setup for the default scope
I have a simple ticket logging application build on LAMP. I am currently playing

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.