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
    Regular Coder
    Join Date
    Jan 2013
    Location
    Sunnyvale, CA
    Posts
    140
    Thanks
    10
    Thanked 7 Times in 7 Posts

    Unhappy CSS background-position problem

    This is an embarrassing newbie question, since I should know this:

    I've got background-position: center center; for a block element somewhere in my page, and the image appears to be centered within the page and not its container. I did not expect that! Is that really the way it works? If so, is there a way to center the image within its container?

    Thx

  • #2
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,693
    Thanks
    22
    Thanked 1,831 Times in 1,815 Posts
    Hello sbhmf,
    The background image should be centered in it's containing element, not the page. Show us an example.
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #3
    Regular Coder
    Join Date
    Jan 2013
    Location
    Sunnyvale, CA
    Posts
    140
    Thanks
    10
    Thanked 7 Times in 7 Posts
    You are correct, at least that's what I've always been doing.

    Want to replicate the issue? I just figured it out: Try adding 'background-attachment: fixed;' to your element and see what happens to it's background image (at least in IE 10).

    Thanks for responding so quickly...


  •  

    Posting Permissions

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