PDA

View Full Version : CSS Div centering problem


backside
09-27-2005, 02:19 AM
Hello,

Theres probably a pretty simple answer to this question but I've wasted too much time already.

I have a div element which contains 2 child div elements. I want the first child div element to be aligned to the left and the second div child element to be centered on the page.

Here's some code:

<div style="background-color: #F0F0F0;">
<div style="display: inline; font-size: small; text-align: left"> aligned left </div>
<div style="display: inline; font-size: medium; text-align: center;"> centered </div>
</div>

Note I'm using display inline because I don't want it to break between each div (meaning I want the contents on both divs displayed on one line).

-Backside

_Aerospace_Eng_
09-27-2005, 04:17 AM
Looks like you want a two column layout. You will need to give a width to the left div, float it left and give the right div enough left margin to clear the left div. For an example go to this page. http://bonrouge.com/2c-hf-fluid.php