1

Good day! I did some reasearch and I read here difference between css height : 100% vs height : auto

that height-auto should take the minimum amount of space depending on the children's width.

In my case, the property behaves like width 100%, taking 100% of it's parent's width

Here is the code:

<!DOCTYPE html>
<html>
<head>
<style>
 .header2 {
            float:left; 
            width:900px;
            height:23px;
            background:red;
        }
.buttonHolder {
    margin: 0 auto;
    width:auto;  
    height:24px;
    background:black;
}

.button {
     width:50px;
    height:24px;
     background:blue;
     float:left;
}
</style>
</head>
    <body>
      <div class="header2">
                <div class="buttonHolder">
                    <div class="button"></div> <div class="button"></div> <div class="button"></div>
                </div>
            </div>
    </body>

The question is: Where is my error?

Community
  • 1
  • 1
Stanimirovv
  • 3,064
  • 8
  • 32
  • 56

1 Answers1

0
.header2 {
            float:left; 
            width:900px;
            height:23px;
            background:red;
            text-align: center;
        }
.buttonHolder {
     display: inline-block;


    height:24px;
    background:black;
}

this should work.

Gangadhar
  • 1,739
  • 15
  • 19
  • It works, however it breaks the 'margin: 0 auto;' which I use to center the div, so it fixed the question but opens a new bug. – Stanimirovv Jul 16 '13 at 07:41
  • it is aligning in the center of the .header2 div. if you want total container in the center you can put margin:0 auto for .header2 and remove float:left – Gangadhar Jul 16 '13 at 07:53