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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:48:55+00:00 2026-06-09T14:48:55+00:00

I need to horizontally (I don’t care vertically) center three boxes (div or span,

  • 0

I need to horizontally (I don’t care vertically) center three boxes (div or span, I don’t care) such that the mid one is always centered and its width is the smallest needed for the text (a single word) it contains, in the following way:

with a short text (a sigle word):

--------------------------------------------------------------
|                                                            |
| ----------------------  ----------  ---------------------- |
| |                    |  |xxxxxxxx|  |                    | |
| |                    |  |        |  |                    | |
| ----------------------  ----------  ---------------------- |
|                                                            |
--------------------------------------------------------------

with a long text (a single word, again):

--------------------------------------------------------------
|                                                            |
| -----------  ------------------------------  ------------- |
| |         |  |xxxxxxxxxxxxxxxxxxxxxxxxxxxx|  |           | |
| |         |  |                            |  |           | |
| -----------  ------------------------------  ------------- |
|                                                            |
--------------------------------------------------------------

Is this possible?

My last temptative is far from success (since the boxes overlap, and I don’t want this):

<div style="position:relative;";>
<span style="display:block;width:100px;margin:0 auto;text-align:center;border:1px solid red"><h1>mid_text</h1>
<span style="text-align:right;position:absolute;top:0em;left:0;display:block;width:50%;float:left;border:1px solid red">left text</span>
<span style="text-align:left;position:absolute;top:0em;left:50%;display:block;float:right;width:50%;border:1px solid red">right text</span>
</span>
</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-09T14:48:56+00:00Added an answer on June 9, 2026 at 2:48 pm

    CSS

    Add this to your CSS file:

    body
    {
        padding:20px;
    }
    .wrapper
    {
        display:table;
        width:100%;
    }
    .wrapper .left,
    .wrapper .center,
    .wrapper .right
    {
        padding:0 20px;
        display:table-cell;
    }
    .wrapper .left,
    .wrapper .right
    {
        width:50%;
        background-color:#2b88f1;
    }
    .wrapper .center
    {
        text-align:center;
        background-color:#fff;
    }
    

    HTML

    And this is what your HTML code should look like:

    <div class="wrapper">
       <div class="left">
           left
        </div>
        <div class="center"> 
            center
        </div>
        <div class="right">
            right
        </div>
    </div>
    
    <hr>
    
    <div class="wrapper">
       <div class="left">
           left
        </div>
        <div class="center"> 
            ceeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeenter
        </div>
        <div class="right">
            right
        </div>
    </div>
    

    ​
    Example: http://jsfiddle.net/YVhLt/

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

Sidebar

Related Questions

Possible Duplicate: How to center div horizontally and vertically I need to put image
I would need to build a html table that has a horizontally scrollable column.
My page has 3 divs that are located horizontally. I need to make the
i need to concatenate images in php (two or more), both vertically and horizontally.
i need horizontal scrolling script in javascript, but don't have much time to write
I need to make the images show up side by side horizontally in the
I need to disable slickgrid horizontal scrollbar. I have only one column and have
I'm using Java Swing. I have a textarea in a panel. I don't need
I have two <div> , one nested into the other defined like this: <div
I'm creating a horizontal menu bar. There is an outer div that contains inner

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.