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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:05:14+00:00 2026-05-27T04:05:14+00:00

How would you center position two divs inside a container when one is ‘dynamic’?

  • 0

How would you center position two divs inside a container when one is ‘dynamic’? That is, the search input in content-top-search changes width from 226 to 462 when you click inside it.

Here’s my CSS code:

.content-top-buttonsearch-holder {
    text-align: center;
    float: left;
    width: 816px;
    margin-left: 15px;
}
.content-top-buttons {
    height: 31px;
    width: 269px;
    float: left;
    margin-right: 16px;
}
.content-top-search {
    height: 31px;
    float: left;
}

Here is my HTML:

<div class="content-top-buttonsearch-holder">
    <div class="content-top-buttons">
        <a id="all_events_button" href="#" title="Click to show all events happening!"></a>
        <a id="all_venues_button" href="#" title="Click to show all venues in our database!"></a>
        <a id="event_finder_button" href="#" title="Click to search for events!"></a>
    </div>
    <div class="content-top-search">
        <input name="venue-search" class="searchbox" onclick="this.value='';" onfocus="this.select()" onblur="this.value=!this.value?'sort parties by venue name':this.value;" value="sort parties by venue name" />
    </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-05-27T04:05:15+00:00Added an answer on May 27, 2026 at 4:05 am
    <div style="border: 1px solid green; margin: 10px;">
        <div style="margin: 10px auto; width: 50%; border: 1px solid red; text-align:right">center 1</div>
        <div style="margin: 10px auto; width: 80%; border: 1px solid magenta; text-align:left;">center 2</div>
    </div>
    

    what’s really the ‘magic’ is the margin-left|right: auto in the inner divs. Also they have to have a width.


    edit
    This will not work with floats


    edit2
    Try disabling the float on .content-top-search Maybe that is what you want.


    edit3
    http://jsbin.com/ukuqas/5 has another solution
    there you have a outer container with text-align: center and an inner container with display: inline-block This inner container containes the buttons and the search box. All float is prohibited.

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

Sidebar

Related Questions

I have two divs, one on the left, and one on the right side
I'm making a program that let me click on the center of two concentric
I have an aspx Login control and I would like to center it on
I would like to Show my Messagebox in the center of its parent form.
I have written a plugin for Windows 7 Media Center, and I would like
When I add an observer to the default notification center, where would I unregister
Would having a nice little feature that makes it quicker to write code like
So I'm designing a myspace page and I have two images, one is a
I have a map that has checkboxes for users to select what they would
I have two images that I want to be positioned directly on top of

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.