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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:04:45+00:00 2026-05-29T10:04:45+00:00

#container { background: #787234; width:980px; height:auto; margin-left: auto; margin-right: auto; position:relative; //float:left; } container

  • 0
 #container
 {
   background: #787234;
   width:980px;
   height:auto;
   margin-left: auto;
   margin-right: auto;
   position:relative;
   //float:left;
}

container height is set to auto. Still I am facing height issue. Since the DIV is aligned to center I am not able to use float:left.

Please tell me how to get the height:auto without using float:left

here is the code snippet

Edit:

float:left is giving me the result but my div won’t be in center if I use float:left.

Solved: (Not having 100 Reputation to Answer this )

Since the #container is aligned to center, it’s giving me height:auto issue. I solved by creating a sub-container div having float:left

Hence, float:left is the answer which I cannot use in #container.

#container
{
  width:980px;
  margin-left: auto;
  margin-right: auto;
}

#sub-container
{
  width:100%;
  height:auto;
  float:left;
  background: #FFF;
}
  • 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-29T10:04:46+00:00Added an answer on May 29, 2026 at 10:04 am

    You do not seem to understand what your CSS is doing. You are aligning the div to the center using margin-left and margin-right, then you also want to float it to the left. These two styles are in conflict and will not work. Either you want the div in the middle, or on the left, it can’t be both at the same time.

    Also, the height is set to auto by default so you shouldn’t have to explicitly state this.

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

Sidebar

Related Questions

#container{ background:url(images/bg-main.png) repeat-y; width: 903px; background-position: 0px 687px; background-position: bottom; height: 1200px; margin-left: auto;
I have a container background defined in CSS like this; .container { background:#fff; margin-left:auto;
* { font-family:verdana; font-size:12px; line-height:16px; margin:0 auto; padding:0; } body { background-color:#609fdf; color:#4d4c4c; padding:40px
I can position a small background-image/icon 4 pixels from the center left of its
I have this css code #storage_screen { top: -100%; width: 100%; height: 100%; background:
This is the HTML layout: <div class=wrap> <div id=container> <div id=left>...</div> <div id=right>...</div> </div>
i did't find any property of a tab container to change background color of
I have a container (div) with a background image. In this div there is
For a background job which I would like to run in a J2EE container,
Given IE6, an UL-LI list and a background image for the UL container. <style>

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.