Reply
positioning 2 div containers in main container
Old 05-03-2008, 12:23 PM positioning 2 div containers in main container
Average Talker

Posts: 22
Name: Adrian
I have been trying to place div containers into a main content div container. When I place the containers I have trouble as they don't want to align evenly, I've tried using absolute and relative on the 2 div containers but either one floats to the right or overlaps the other.

I have main div content container: (contentWrapper)
centered on page
width: 957px
height: 342px

left div container: (leftContent)
width: 313px
height 320px
margin: 19px 0 81px 32px

right div container: (rightContent)
width: 494px
height: 342px
margin: 19px 71px 30px 0

So basically its a main content container with 2 column containers inside of it.

I have tried coding it like this:

html:

<div id="contentWrapper">
<div id="leftContent">Left Content Blah Blah Blah </div>
<div id="rightContent">Right Content Content Blah Blah Blah </div>
</div>


css:

#contentWrapper {
border: 1px solid black;
height: 342px;
width: 957px;
margin: 0 auto;
position:relative;
}

#leftContent {
position:absolute;
top:0;
left:0;
width:313x;
height:320px;
border: 1px solid red;
}

#rightContent {
position:absolute;
top:0;
right:0;
width:494x;
height:342px;
border: 1px solid red;
}


What happens to the boxes is that they are not proportional to the sizes I have given them and I want to be able to move them inside the main content container so I can have the padding of 32px from left side and padding of 71 from right side. Not sure if the correct way is to use padding or margins to position the entire 2 containers inside the main container?

Please someone let me know if I'm coding this the correct way through CSS? Thanks.
elv8 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 05-03-2008, 01:05 PM Re: positioning 2 div containers in main container
chrishirst's Avatar
Super Moderator

Posts: 11,498
Location: Blackpool. UK
Get RID! of the position absolutes and float left the two containers inside the wrapper, use position relative on the wrapper and the left container and use margins to set the right container.

clear the floats before closing then wrapper element.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-03-2008, 01:21 PM Re: positioning 2 div containers in main container
Average Talker

Posts: 22
Name: Adrian
I have done as you said but as a result I get the left container on the top and the right container on the bottom instead of the 2 containers side by side?
elv8 is offline
Reply With Quote
View Public Profile
 
Old 05-03-2008, 01:34 PM Re: positioning 2 div containers in main container
wayfarer07's Avatar
Insomniac

Posts: 487
Name: Abel Mohler
Location: Asheville, North Carolina USA
is the code you posted the actual code from the site you're building? Because there are two typos: "width:313x;" should be "width: 313px;" and "width:494x;" should be "width: 494px"
__________________
Go FREELANCE <=====||=====> Hire Me
wayfarer07 is offline
Reply With Quote
View Public Profile
 
Old 05-03-2008, 01:46 PM Re: positioning 2 div containers in main container
Average Talker

Posts: 22
Name: Adrian
It is 3am and yes I did typo, now is all fine and working!!!

Thank you for your help!!! :-)
elv8 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to positioning 2 div containers in main container
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13818 seconds with 13 queries