SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Centering background image in IE

    I've been working on a site that uses a vertical line pattern for a background. It's here:

    http://www.redpepperinc.com/ernst/nclanding.html

    Here's what I have done:

    I have a 6 pixel wide vertical line for the background. This pattern is also contained in the body of the page so I need to make sure that they align perfectly.

    The wrapper div for the page is a specific width and centered on the page with auto left and right margins.

    The background image is set to "center top repeat". So, theoretically 3px of the background image are to the left of the exact center point of the window and 3px are to the right of the exact center point of the window.

    The background image is set in the body image exactly the same way.

    Works exactly as I would expect it to in:

    Mac:
    Safari 3.0.4
    Firefox 2.0.0.12
    Opera 9.5
    Camino 1.5.5
    Flock 1.1

    Windows:
    Firefox 2.0.0.12
    Safari 3.0.4
    Netscape 8.1.2


    However...

    In IE7.0.5730.11

    the centering of the background is not being respected properly and it is off by a pixel or maybe two. You can see it at the bottom of the content, just under the copyright credit and also on the left and right sides as you widen your browser window.

    So, I did this simple test:

    http://www.redpepperinc.com/ernst/centertest.html

    and sure enough it displays properly in ever browser BUT IE7 (I don't have access to any earlier versions of IE). There the background line does not line up perfectly.

    Anyone know of a workaround for IE for this issue? Is this a known issue?

    Thanks for any help and/or insight.

  2. #2
    Design Your Site Team bronze trophy Erik J's Avatar
    Join Date
    May 2007
    Location
    Countryside, Sweden
    Posts
    3,407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If viewport gets narrower than page, the page is not centered on body.

    Try set a "min-width:800px" on body.
    Happy ADD/ADHD with Asperger's

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the input, but it's not related to the viewport being smaller than the page. The problem exists no matter how big the viewport is. I actually found documented information about the issue - "The One Pixel Background Jog" here: http://www.pmob.co.uk/temp/onepxjog.htm. Their solution solved my problem.


Bookmarks

Posting Permissions

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