no scroll background

  • jannin
  • Beginner
  • Beginner
  • User avatar
  • Joined: Nov 30, 2003
  • Posts: 40
  • Loc: Cranbrook, BC Canada
  • Status: Offline

Post April 14th, 2004, 7:06 pm

Okay, sorry about the unclear title...
I'd like to know how backgrounds are made so they don't scroll with the text on the page?

Probably another easy answer that I could figure out, but ever since I found this forum I've been becoming more and more dependent upon it...

Einh.
Thanks in advance!

/jannin
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 14th, 2004, 7:06 pm

  • Nunzio390
  • Student
  • Student
  • User avatar
  • Joined: Mar 22, 2004
  • Posts: 70
  • Loc: Tharsis Ridge (Martian lowlands)
  • Status: Offline

Post April 14th, 2004, 7:30 pm

Code: [ Select ]
<style type="text/css">
body { background-image: url(background.gif); background-attachment: fixed; }
</style>
  1. <style type="text/css">
  2. body { background-image: url(background.gif); background-attachment: fixed; }
  3. </style>


The above assumes your background image is named background.gif
Could be any background image though.
  • digitalMedia
  • a.k.a. dM
  • Genius
  • User avatar
  • Joined: Dec 29, 2003
  • Posts: 5169
  • Loc: SC-USA
  • Status: Offline

Post April 14th, 2004, 7:54 pm

you could also use the shorthand version

Code: [ Select ]
<style type="text/css">
body { background: url(background.gif) fixed; }
</style>
  1. <style type="text/css">
  2. body { background: url(background.gif) fixed; }
  3. </style>


save a couple key strokes anyway ;)
- dM
  • Sonire
  • Novice
  • Novice
  • No Avatar
  • Joined: Apr 12, 2004
  • Posts: 33
  • Status: Offline

Post April 14th, 2004, 8:56 pm

Not to mention.....

{body background img fixed src="location"}

Actually, I could be incorrect about this one. It's been a while since ive use an image for a background. I think that will work though. some one correct me if I'm wrong.
  • gsv2com
  • Professor
  • Professor
  • User avatar
  • Joined: Jan 25, 2004
  • Posts: 776
  • Loc: Nippon
  • Status: Offline

Post April 15th, 2004, 5:40 am

Sonire, what the heck is that?

HTML uses < and >
CSS uses { and }
  • jannin
  • Beginner
  • Beginner
  • User avatar
  • Joined: Nov 30, 2003
  • Posts: 40
  • Loc: Cranbrook, BC Canada
  • Status: Offline

Post April 15th, 2004, 3:51 pm

heh, thanks all,

actually I got impatient and figured that part out on my own :oops:
but now I'd like to know...
is there any way to use the codes you've given me, and change the size of the image so it's the same size as the screen (100%)?

Tried to find that out on my own, didn't work too well. x.x

Thanks again!
/jannin
  • Nunzio390
  • Student
  • Student
  • User avatar
  • Joined: Mar 22, 2004
  • Posts: 70
  • Loc: Tharsis Ridge (Martian lowlands)
  • Status: Offline

Post April 15th, 2004, 5:15 pm

CSS cannot be used to accomplish what you want, but other techniques can be used. Look at tedster's replies in this thread, and also look at the very last reply by starway...

http://www.webmasterworld.com/forum83/303.htm
  • gsv2com
  • Professor
  • Professor
  • User avatar
  • Joined: Jan 25, 2004
  • Posts: 776
  • Loc: Nippon
  • Status: Offline

Post April 15th, 2004, 6:52 pm

Nunzio390 wrote:
CSS cannot be used to accomplish what you want, but other techniques can be used. Look at tedster's replies in this thread, and also look at the very last reply by starway...

http://www.webmasterworld.com/forum83/303.htm


For proof that you can do this with CSS, look at http://www.gsv2.com/en/?p=gallery

The dj image on the bottom right is a fixed background.
  • Nunzio390
  • Student
  • Student
  • User avatar
  • Joined: Mar 22, 2004
  • Posts: 70
  • Loc: Tharsis Ridge (Martian lowlands)
  • Status: Offline

Post April 15th, 2004, 8:47 pm

Errrr... I don't see any indication on that Groove Seeker page where any background image has been resized to stretch to accommodate 100% of the width and height of a user's screen resolution. The Groove Seeker page you linked to above is however a perfect example of a fixed background in use, which is what jannin's first question in this thread was asking, and which I and others already responded to immediately after. I supplied the CSS to show how to do so and digitalMedia gave a shortened version. I am not disputing that a fixed background is possible. It most definitely is. When I answered jannin above (and where you quoted me), I answered in direct response to and immediately following jannin's 2nd question in this thread, quoted below and highlighted in italic bold...

jannin wrote:
heh, thanks all,

actually I got impatient and figured that part out on my own :oops:
but now I'd like to know...
is there any way to use the codes you've given me, and change the size of the image so it's the same size as the screen (100%)?

Tried to find that out on my own, didn't work too well. x.x

Thanks again!
/jannin
  • gsv2com
  • Professor
  • Professor
  • User avatar
  • Joined: Jan 25, 2004
  • Posts: 776
  • Loc: Nippon
  • Status: Offline

Post April 15th, 2004, 10:20 pm

My bad, I thought we were still discussing the fixed background issue. Guess I should take my own advice and READ before posting. :)
  • jannin
  • Beginner
  • Beginner
  • User avatar
  • Joined: Nov 30, 2003
  • Posts: 40
  • Loc: Cranbrook, BC Canada
  • Status: Offline

Post April 22nd, 2004, 8:00 pm

Slight problem, Nunzio390, I can't enter that thread, it's members only, and I'd have to pay to register.

Any other ideas?

/jannin
  • Nunzio390
  • Student
  • Student
  • User avatar
  • Joined: Mar 22, 2004
  • Posts: 70
  • Loc: Tharsis Ridge (Martian lowlands)
  • Status: Offline

Post April 22nd, 2004, 8:25 pm

jannin....

Are you referring to this thread? ...
http://www.webmasterworld.com/forum83/303.htm

It's true that you can't reply to any thread there without first registering and then logging in. But you most certainly do not have to pay to register there. It's a forum, similar to here at Ozzu.

Go ahead and register there, if you'd also like to post there too...
http://www.webmasterworld.com/reg.cgi
  • Truce
  • Guru
  • Guru
  • No Avatar
  • Joined: Apr 25, 2004
  • Posts: 1477
  • Loc: Washington DC
  • Status: Offline

Post April 25th, 2004, 9:17 pm

You could also do a resolution check and then redirect to a separate page so it all fit correctly.

more on how to do this at <a href="http://www.dynamicdrive.com">Dynamic Drive</a>
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Mar 24, 2004
  • Posts: 1855
  • Loc: Uk
  • Status: Offline

Post April 26th, 2004, 12:00 am

have the image position absolute, in the top left corner, stretched 100% and then set the z-index so its behind everything!

Wil that work?

sorry - i was just leaving for work when I wrote that...
try:
PHP Code: [ Select ]
 
img#backgroundimage{
 
    position: fixed;
 
    left: 0px;
 
    top: 0px;
 
    width:100%;
 
    height:100%;
 
    z-index:0;
 
}
 
 
  1.  
  2. img#backgroundimage{
  3.  
  4.     position: fixed;
  5.  
  6.     left: 0px;
  7.  
  8.     top: 0px;
  9.  
  10.     width:100%;
  11.  
  12.     height:100%;
  13.  
  14.     z-index:0;
  15.  
  16. }
  17.  
  18.  

Then place the image you want for your background in an img with id="backgroundimage".

I don't know if that z index will work, you might need to set some other z-indeces on other elements. Have a go and see what happens, unless someone else has already tried this and it doesn't work lol.

If you are going to check for screen size, then don't do a redirect, just put something like this in your title tag:
PHP Code: [ Select ]
 
<style>
 
    body{
 
        background-image:url(default/image/path)
 
        background-position: center;
 
        background-attachment:fixed;
 
        background-repeat:none;
 
}
 
 
 
</style>
 
<script>
 
/*insert code here that will detect window size and select the most appropriate image for the background.  Store the image path in the imaginatively titled variable "ImagePath"*/
 
writeln('<style>body{background-image:url('+ImagePath+');background-position: 0px 0px;}</style>')
 
</script>
 
 
 
 
  1.  
  2. <style>
  3.  
  4.     body{
  5.  
  6.         background-image:url(default/image/path)
  7.  
  8.         background-position: center;
  9.  
  10.         background-attachment:fixed;
  11.  
  12.         background-repeat:none;
  13.  
  14. }
  15.  
  16.  
  17.  
  18. </style>
  19.  
  20. <script>
  21.  
  22. /*insert code here that will detect window size and select the most appropriate image for the background.  Store the image path in the imaginatively titled variable "ImagePath"*/
  23.  
  24. writeln('<style>body{background-image:url('+ImagePath+');background-position: 0px 0px;}</style>')
  25.  
  26. </script>
  27.  
  28.  
  29.  
  30.  

Saves you messing around with multiple pages and all that. It also gives you a handy alternative to those people who have javascript switched off.

BTW I have tested none of the code here so it will all need debugging....
CSS website design tutorials
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Joined: Mar 24, 2004
  • Posts: 1855
  • Loc: Uk
  • Status: Offline

Post April 26th, 2004, 4:14 am

Ok, I have now tried the first one...

It works if:

a)everything else on your page has a higher z-index AND everything else on the page is absolutely positioned (Or you have to put the image as the first object in the body tag.

b) you are not using IE (IE can't cope with fixed position stuff too well, there may be a hack but I don't know it...)

So possibly best to ignore that one, The second one should still work...

//edit: in case you were wondering, the background-size property should be introduced for css3:
http://www.w3.org/TR/2002/WD-css3-background-20020802/#background-size
CSS website design tutorials
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post April 26th, 2004, 4:14 am

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: ScottG and 151 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.