Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

HELP! CSS background-attachment Property problems...?

I need to fix a background in an element so it won't move when you scroll the text in it...

I used the background-attachment: fixed; line but that fixes the background image to the top left corner of the browser window, not to the actual element in question... So now the background, which used to fit the element perfectly is now way off line...

I've also tried using background-position: xpx ypx; command which works, but not if you alter the size of the browser window/desktop resolution...

What am I doing wrong and how can it be fixed?!?

1 Answer

Relevance
  • Anonymous
    1 decade ago
    Favorite Answer

    Not going to guess because guess never seem to work depending on the code used on the page. If you just use the background styling with just the fixed part, you need to add the positioning for the background as well. I don't know if you are using table tags (outdated since late 1990s) or divs and CSS (preferred). Also, don't know if you are using a tiled image or not. So many reasons NOT to guess, but here it is:

    background: #fff url(path to image) no-repeat center fixed;

    You must set the container with a width/height to use with bg image. Set #fff to bg color of choice.

    Ron

Still have questions? Get your answers by asking now.