ebm
09-30-2008, 04:25 AM
I am working on a web page where I am trying to have text aligned left, center, and right within a container div (think 3 titles in newspaper columns for a visual). The closest I have gotten aligns everything correctly, but on separate lines. The CSS of my test file is:
<style type="text/css">
.container {
height:20px;
width:800px;
text-align:center;
}
.left {
float:left;
}
.center {
margin-left:auto;
margin-right:auto;
}
.right{
float: right;
}
</style>
And the HTML is:
<div class='container'>
<div class='center'>Center</div>
<div class='left'>Left</div>
<div class='right'>Right</div>
</div>
If I put a float:left in the Center div, that puts everything on the same line, but the text is no longer centered. Thanks for taking a look.
<style type="text/css">
.container {
height:20px;
width:800px;
text-align:center;
}
.left {
float:left;
}
.center {
margin-left:auto;
margin-right:auto;
}
.right{
float: right;
}
</style>
And the HTML is:
<div class='container'>
<div class='center'>Center</div>
<div class='left'>Left</div>
<div class='right'>Right</div>
</div>
If I put a float:left in the Center div, that puts everything on the same line, but the text is no longer centered. Thanks for taking a look.