View Full Version : Can't Wrap my DIV's

11-07-2009, 02:44 PM
I wanted to create a Wrap around my divs but it doesn't work. The only thing that works about the wrap is that it becames all relative and move along the browser. The wrapper was supose to be under my other divs with a background and border color, and all other divs will be inside of it, but instead its sitting on the top by itself. The width is 950px and it has no height because i wanted to auto adjust while i design and add more divs, and the wrapper has a padding of 10px.

What could be wrong ?


11-07-2009, 04:48 PM
Absolutely positioned elements do not add height to their parent tags. They are positioned relative to the parent (if the parent has a CSS position property applied) but they don't affect the size or content of their parent.

Bottom line, don't use absolutely positioned divs for page layout.

11-07-2009, 08:32 PM
OK.. what i did now was that i changed all the divs inside the parent to relative and now it works.... So now the only one with a relative position is the parent and all inside Divs are relative... at least it works now like i wanted.... thats whats you meant right ?

11-07-2009, 10:28 PM
Sorry, that's not what I meant and I think you'll find (as you get further into the design) that it really doesn't work the way you want.

I meant you need to learn to layout pages without using the position property at all. Hopefully someone here can point you to a good tutorial or I try to locate one when I'm back in the office.

11-08-2009, 02:07 AM
Thanx... i'll keep trying and hope to get some good tutorial..!!

11-08-2009, 11:39 AM
This is reaaly a good and well explained tutorial with the very basics of CSS:

CSS tut from Smashing Magazine (http://www.smashingmagazine.com/2009/10/05/mastering-css-coding-getting-started/)

You will learn how to position a layout just with floats, margins and paddings.

The position: absolute is a very powerful CSS property and it's very easy to position a div with the properties 'top' and 'left' wherever you want, but if you build your whole layout with it your site is gonna load much and much slower compared to a layout positioned with floats.