On Jan 25, 2010, at 12:07 PM, Rod Castello wrote: > > > --- On Mon, 1/25/10, Michael Beaudoin <[email protected]> wrote: > > From: Michael Beaudoin <[email protected]> > Subject: Re: [css-d] centering divs within a div... > To: [email protected] > Date: Monday, January 25, 2010, 5:47 PM > > > > On Mon, Jan 25, 2010 at 12:29 PM, Michael Beaudoin <[email protected] > > > wrote: > >> Ok. An easy one for some of you on a Monday, but I'm just not > >> seeing it. > >> > >> I have a div (content) and would like to center two other divs > >> (leftContent and rightContent) within the content div. > >> > >> I've tried all the obvious things but they aren't working for me. > >> > >> Thanks, > >> Michael > > On Jan 25, 2010, at 11:42 AM, Troy Harshman wrote: > > > Well, you've got everything wrapped in a fixed width div. So why not > > do some math and set widths to your content divs and then position > > with margins? > > Well, I need the width to expand, just changed it to 100%, but I still > need the leftContent and rightContent to center within the Content > div. > > Michael > > --------------------------------- > > Try setting the widths of each inside div to percentages: > Right div width 40% > right div padding 4% (x2 =8%) > Left div width 40% > left div padding 4% (x2 =8%) > > The padding can be adjusted to suit your taste, or you can use > margins instead. > > Total % = 96% of the containing width of 100% itself. These numbers > can be adjusted to get closer to 100%, but be careful that they > don't go over 100%. I would try to stay a little bit below. The > strokes will add into the total width as well. > > Add 1px border on each div so you can see them. > Give each div a height, or add some content such as text and you > should be able to test the results. > > Also, they need to be floated left. Or you can float the left one > left, and the right one float right. Either way should work. > Good luck. > Rod Castello > http://rodcastello.com
That did it. I appreciate the help. At first I was not adding a width to the divs, but when I did it was at 100%. For some reason it worked at below 100%. Thanks to all for your help. Michael ______________________________________________________________________ css-discuss [[email protected]] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
