gilyotina
05-02-2008, 09:19 AM
hi,
just when i thought i understood the concept of floated divs..
i have 2 divs inside my container div.
the first div, "article", is set to float:left.
the other div acts strange. when i set it to float:left, the width of the div is correctly 300px. However, i cannot make it horizontally centered (by using margin: 0 auto;). WHY CANT IT BE CENTERED?
when i remove the float:left from that second div ("sidebar"), its size changes to 150px. And still, it cannot be centered. WHY DOES THE SIZE CHANGE?
I attach 2 images of the page.
this is the relevant css code:
#container{
background-color: #FFFFFF;
width:750px;
margin:0 auto;
min-height:450px;
}
#article{
margin-top:20px;
padding-left:5px;
width:370px;
background-color:#CCFF66;
float:left;
}
#sidebar{
width:300px;
margin:20px auto;
padding:0;
background-color:#CCCC66;
}
tnx
just when i thought i understood the concept of floated divs..
i have 2 divs inside my container div.
the first div, "article", is set to float:left.
the other div acts strange. when i set it to float:left, the width of the div is correctly 300px. However, i cannot make it horizontally centered (by using margin: 0 auto;). WHY CANT IT BE CENTERED?
when i remove the float:left from that second div ("sidebar"), its size changes to 150px. And still, it cannot be centered. WHY DOES THE SIZE CHANGE?
I attach 2 images of the page.
this is the relevant css code:
#container{
background-color: #FFFFFF;
width:750px;
margin:0 auto;
min-height:450px;
}
#article{
margin-top:20px;
padding-left:5px;
width:370px;
background-color:#CCFF66;
float:left;
}
#sidebar{
width:300px;
margin:20px auto;
padding:0;
background-color:#CCCC66;
}
tnx