PDA

View Full Version : DIV tag position in CSS



yunakokimama
27 Jan 2007, 04:32 PM
There is position CSS, Fixed, Absolute, Relative. Which one is the best to use??? I want to prevent corrupt table in some explorer.

Wickham
28 Jan 2007, 02:59 AM
Do not use position:fixed as it doesn't work in IE6; it is for special situations only.

If you are a beginner with CSS I would recommend that you use position: absolute for all divs and elements. The top and left positions are normally taken from the top left corner of the viewing window and so you just set each div, image, element where you want it with a stated width, leaving a bit of space below each in case someone uses larger text and the div needs to expand down. Each div is positioned independently and other divs do not affect any others. When a window is made smaller the divs mantain their positions and scrolling is needed to view some of them.

Position:relative (or just not stating any position) sometimes makes divs and elements float around according to the window size so some experience is required to avoid bad display. This method can be used to make a page expand or contract to fit any window size (except very small windows).

You can also use mixed position:relative divs with position:absolute divs inside where they take their position from the top left corner of the position:relative div.

See http://www.wickham43.supanet.com/tutorial/divboxes.html (and the next page which is all floated divs with no position stated).