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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:51:46+00:00 2026-06-07T11:51:46+00:00

This should be a basic css question, but as we all know sometimes it

  • 0

This should be a basic css question, but as we all know sometimes it can be a tricky language.

<div id="main">    
    <div id="container">
        <div class="item">
        <div class="item">
        <div class="item">
        <div class="item">
        <div class="item">
        <div class="item">
    </div>
</div>

#main {clear: both; margin: 20px auto; max-width: 100%; width: 1000px;}
#container {clear: both; margin: 0 auto; max-width: 832px;}
.item {width: 208px; float: left;}

By default, there are 4 .items in a row. When I resize my browser window to smaller than 832px wide, the .items jump down to fit 3 in a row.

How do I center the 3 items within the #container or make the #container width equal to the width of its floated contents and center the #container in the #main?

mockup

  • 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-07T11:51:49+00:00Added an answer on June 7, 2026 at 11:51 am

    I believe this is more or less what you want:

    http://jsfiddle.net/L3JVe/17/

    It was a simple fix. I set your .items to display:inline-block; and your #container to text-align:center;.

    Your new CSS will look something like this:

    #main {
        clear: both;
        margin: 20px auto;
        max-width: 100%;
        width: 1000px;
    }
    
    #container {
        clear: both;
        margin: 0 auto;
        max-width: 832px;
        text-align:center; /*New*/
    }
    
    .item {
        width: 208px; /*May need to adjust*/
        display:inline-block; /*New*/
    }​​​​​​​
    

    Also, you’ll need to remove all space between the items in the HTML to avoid space appearing between the rendered items. (Thanks, @thirtydot!)

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

Sidebar

Related Questions

I know this should be a basic question but I am hitting a brick
This should be a very basic design question, but for some reason it doesn't
Really simple question: Am I missing something? Seems like this should be all that
This is a basic question but google didn't provide any help. I have a
I'm trying to accomplish something that should be rather basic in CSS but I'm
This basic app which was given to me as an project should run quite
I'm trying to learn this basic thing about processors that should be taught in
This should be a no brainer but I have a small mystery with the
This should be simple, but I'm getting confused. I have a parent/child tables -
This should be a simple answer. I'm just not knowledgeable enough in CSS to

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.