Web Analytics Made Easy -
StatCounter DIV problem... - CodingForum

Announcement

Collapse
No announcement yet.

DIV problem...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DIV problem...

    i normally use position:absolute to position DIV's on an XHTML page which works ok.

    Now, i'm trying to include one XHTML page inside another using the PHP include() command.

    Trouble is, that instead of being contained inside it's own DIV, the absolutley positioned elements appear x pixels from the left and y pixels from the top of the page rather than from the top of the <div> in which they are enclosed.

    Any ideas? I never could get my head round all these div positioning commands...
    My body's a temple... and like those ancient Greek ones it's a ruin
    sweenster.co.uk

  • #2
    On the containing div, you need position: relative to 'reset' the positioning co-ordinates.
    David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
    W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

    Comment


    • #3
      nice one.

      on a related topic -

      how do you center-align a page with relative <div>'s??

      as an example look at:


      you'll see that everything hangs to the left (if you view it on 1024x748 res or above). how could i get this aligned so that it will center on the page??
      My body's a temple... and like those ancient Greek ones it's a ruin
      sweenster.co.uk

      Comment


      • #4
        Wrap it with another div, then use the negative margin trick on that:
        Code:
        div#everything {
          width: 700px; //for example
          position: absolute;
          left: 50%;
          margin-left: -350px; //half of width
        }
        On a related point, you shouldn't have to do this: technically you could just use body as that should just act like another div. However, guess which browser has viewport problems if you do that
        David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
        W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!

        Comment

        Working...
        X