15 replies [Last post]
barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

I'm currently using a background image on my site: http://www.barkbiteblog.com

I'd like to lock the background image and make it so when the user scrolls up and down, only the content moves, not the background. Also, how can I make it so that the background image scales appropriately for the user's screen resolution? This has been a sticky issue and I'm not sure how to resolve this.

Thanks for any help you all can provide!

Deuce
Deuce's picture
User offline. Last seen 4 weeks 5 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4421
Points: 1840

Research

Research background-attachment: fixed and http://www.cssplay.co.uk/layouts/background.html

all » http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

Verschwindende
Verschwindende's picture
User offline. Last seen 15 weeks 5 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2009-10-09
Posts: 2037
Points: 2256

edit - took too long to

edit - took too long to reply. Already covered.

yet again.

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

Hey Deuce, The link you sent

Hey Deuce,

The link you posted is broken. Do you have another?

Deuce
Deuce's picture
User offline. Last seen 4 weeks 5 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4421
Points: 1840

Link works for me. Do a

Link works for me.
Do a search for "CSS 100% background"

all » http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

Thanks! It's working now.

Thanks! It's working now. Guess it was down temporarily.

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

Ok, so the

Ok, so the background-attachment: fixed; worked. Thanks! But is there a way to make the site/background scale better? I have a 17" MacBook Pro and it looks great on my comp, but on my wife's 13" MacBook Pro it's not as great.

Just as an example: http://www.rollingstone.com . The background image on the site looks great on both my 17" MacBook and my wife's 13". It seems like it's scaling to fit each computer/browser?

Deuce
Deuce's picture
User offline. Last seen 4 weeks 5 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4421
Points: 1840

barkbiteblog wrote: Also,

barkbiteblog wrote:

Also, how can I make it so that the background image scales appropriately for the user's screen resolution?

barkbiteblog wrote:

It seems like it's scaling to fit each computer/browser?

Yup, because that's what you asked for.

all » http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

Deuce
Deuce's picture
User offline. Last seen 4 weeks 5 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4421
Points: 1840

Oh, I see what you're saying

Oh, I see what you're saying now.
The site you mentioned is using javascript to resize an image tag.

all » http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

I meant the RollingStone site

I meant the RollingStone site is scaling. Mine is not.

Deuce
Deuce's picture
User offline. Last seen 4 weeks 5 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4421
Points: 1840

Looks like we posted at the

Looks like we posted at the same time, read above.

all » http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

Deuce wrote: Oh, I see what

Deuce wrote:

Oh, I see what you're saying now.
The site you mentioned is using javascript to resize an image tag.

Ah ha! That's what I figured. Thanks!

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

Hmmm....I'm seeing more and

Hmmm....I'm seeing more and more sites with a background image that spans well across multiple screen sizes.

thafeedback[dot]com
thebrokenbrownegg[dot]com

Can anyone help me optimize my background image so that the container is centered and the sides of my background image peek out on the sides evenly?

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

Just to note: This is the

Just to note: This is the view I get on my MBP. Notice to the right, there's black space. I know this is because I've resized the image down in PhotoShop, but I did that because when I had it at full-size, the site looked terrible on smaller screen sizes.

Screen shot 2010-08-02 at 3.21.55 PM.png

barkbiteblog
barkbiteblog's picture
User offline. Last seen 30 weeks 3 days ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-03-14
Posts: 14
Points: 18

Anyone else have different

Anyone else have different solutions?

Debayan Gupta
Debayan Gupta's picture
User offline. Last seen 1 year 33 weeks ago. Offline
rank Regular
Regular
Timezone: GMT-4
Joined: 2010-08-10
Posts: 45
Points: 51

Image scaling using CSS

I'm not sure whether this will help with a bg, but..

You can use CSS to scale an image (img-tag) - I'm not sure how you can do it for a bg without js.

Here's how:

Choose height/width fit(replace the appropriate places in the code).

You'll need to put the image in a div, like so :

<div id="mainContent"><img alt="snoopy" src="snoopy.gif"/></div>

then do :

	<style type="text/css">
 
body {background:black;overflow:hidden;margin:0;padding:0;text-align:center}
#mainContent {position:relative;top:0;margin:0;border:0;padding:0;height:100%;overflow:hidden} 
#mainContent img {height:100%;border-style:none}
 
	</style>
 
<!--[if IE]>
<style type="text/css">
#mainContent {width:100%;overflow:auto}
</style>
<![endif]-->

Link to example : http://cs.debayangupta.com/web/special/fitImage.htm

Works pretty much everywhere (IE6+8/FF/Chrome/Opera..).

Back when I built this, I was using html 4.01 tr - later, when I tried changing the doctype, it stopped working .. there's probably some dumb thing somewhere causing it.. I'm just too lazy to correct it ('til I _need_ it).