Forum Moderators: not2easy
body {
text-align: center;
}
div#container {
margin: 0px auto;
}
div#one {
float: left;
}
div#two {
float: left;
}
<div id="container">
<div id="one">text</div>
<div id="one">text</div>
</div>
If a remove the float: left, then the container is centered. But if I add the floating divs, the container floats to the left.
I want to position 2 DIV's next to each other centered IN a container DIV which is also centered. How can this be done?
Anand
IE has a bug that will allow a float to increase the vertical dimension of a parent div that uses margin: auto;, so be careful when testing and do read the specs. Testing will help you to fully understand the behavior ramnifications however.
Also, try testing your code and varying the margin values. Experiment with percentages and em. See what behaviors result.
Best of luck!
CSS is not 'theory,' but a very powerful design tool with tremendous potential. And, the potential will only be realized if developers are willing to push beyond perceived limits.