Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post

    push centered div to top of page?

    Here is what I have so far:
    http://queirdo.com/index2.htm

    I just want to center the #content div and have it at the top of the page. I can center it with margin:0, but then on every browser tested (except IE of course because it always does it's own thing) there is a gap between the div and the top of the page. If I try to absolute position it to top:0px it will no longer be centered.

    How can I fix this?

    (Why I am using this layout: I have background images that I want to extend on both sides on larger resolutions, but they won't fit on the page with content on 800X600 resolution, so I just want them to disappear when the window is that small. They need to match up exactly with an image I will put in the #content div, so I need it to be in the same place on every browser. I've tried a bunch of other ways to accomplish what I want, but nothing has worked so I'm trying 2 divs underneath the main content to put my background images in, extending from the center.)

  2. #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,911
    Thanks
    23
    Thanked 1,874 Times in 1,858 Posts
    Hello queirdo,
    Try changing
    Code:
    html, body {
        margin:0;
        padding:0;
    }
    to this -
    Code:
    * {
        margin:0;
        padding:0;
    }
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use a DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  3. Users who have thanked Excavator for this post:

    queirdo (05-04-2009)

  4. #3
    New Coder
    Join Date
    Nov 2008
    Posts
    16
    Thanks
    1
    Thanked 1 Time in 1 Post
    Yes, that works. It turned out it was the margin or padding on the paragraph inside the div that was shifting things down. Thanks!


 

Tags for this Thread

Posting Permissions

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