5
I have several div
with float: left
inside another div, which is their container, according to code:
<div id="container">
<div id="box-1" class="box">1</div>
<div id="box-2" class="box">2</div>
<div id="box-3" class="box">3</div>
</div>
I’m trying to align them horizontally inside the container (as shown below), but I’m not getting it.
Well, I can’t make it work. Follow my CSS and then the result I’m getting.
#container {
width: 100%;
border-color: blue;
text-align: center;
}
.box {
float: left;
width: 100px; height: 200px;
margin: 10px 20px;
}
#box-1 { background-color: red; }
#box-2 { background-color: green; }
#box-3 { background-color: pink; }
Divs aren’t getting aligned like I assumed it would when using text-align: center
in the container. How to achieve the expected result?
Tip: To add IE support that doesn’t interpret
display: inline-block
-> Also add*display: inline; *zoom: 1;
– Leonardo Bosquett
I’m totally disregarding IE :-)
– Tiago César Oliveira
Thanks Tiago, you helped me solve a problem that was getting on my nerves, Thanks..........
– user30017