Results 1 to 2 of 2

Thread: DIV tag position in CSS

  1. #1
    Join Date
    Nov 2006
    Posts
    16

    DIV tag position in CSS

    There is position CSS, Fixed, Absolute, Relative. Which one is the best to use??? I want to prevent corrupt table in some explorer.

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    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).
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •