Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS CSS static background/elements help Re: CSS static background/elements help

#56571
TheDoc
Member
"LEARNINGCSS" wrote:
ok i have dne it but cant understand one thing…

style="background:#09151F url(images/air-plane.jpg) repeat-x fixed left top; "

when i use this above tag it worked

but when i used
style="background-image:imageurl; position:fixed";
then it didn’t worked for me ? why?

image was shown but postiion was not taken

That is because in your first declaration, the "position" was being applied to the background. In your second declaration, the position was being applied to the element. Example:

<div style="background:url no-repeat fixed top left;"> – this would make the background have no repeat, and be in a fixed position (top, left).

The same thing can be done with:

<div style="background:url; background-repeat:none; background-position:fixed top left;"> – note how all of the other declarations in there all apply to the background.

Your second example:

<div style="background:url; position:fixed;"> – this will not position the background as ‘fixed’. Instead, it will position the <div> as fixed.