Forum Moderators: not2easy

Message Too Old, No Replies

Fixed Background?

         

deonholt

6:01 am on Oct 7, 2008 (gmt 0)

10+ Year Member



Hi there. (This is my first post here and thank you for your help.)

I'm having trouble to have the background of my site, be fixed with no repeat.

I have this:
padding: 0 20px;
background-attachment: fixed;
background-image: url(../graphics/background.jpg);
background-repeat: no-repeat;

When having it like above, no background shows.
When I remove
background-attachment: fixed;

the background shows, but scrolls with the page.

What am I doing wrong?

Thanx so long for your help.
Deon

dreamcatcher

7:08 am on Oct 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try moving your code around to call the image first:

background-image: url(../graphics/background.jpg);
background-attachment: fixed;

dc

deonholt

8:22 am on Oct 7, 2008 (gmt 0)

10+ Year Member



Hi there.

Thank you very much for your help. Now
I need to understand something. My question refers to <snip> I have added the background to the body tags and said it must be fixed. this works 100% - but, Why can I do not have the same in one of my <div>'s?

What I want to achieve is to have the background fixed and my div's must be transparent.

Is this possible?
Thanx again.
Deon

[edited by: engine at 10:59 am (utc) on Oct. 7, 2008]
[edit reason] No urls, please post code [/edit]

BadBoyMcCoy

9:27 am on Oct 7, 2008 (gmt 0)

10+ Year Member



OK I think the problem is that the background image is doing what its supposed to do but its showing up somewhere outside of the div so it cant be seen. Try putting "background-position:50% 50%;" in your maincontent div. once its started showqing up you can position it better by messing around with "background-position" you can use pixels as well as percentages but this may not be good idea as the background image will appear to be in different places depending on the screen size. Hope this was some help to you

deonholt

9:37 am on Oct 7, 2008 (gmt 0)

10+ Year Member



Thank you VERY VERY much.

your suggestion works 100% correct (but then you knew it would ;-))

Thanx again!
Deon