OK, after a few hours and some Internet research I think I found a way to spread an image across my page. Let me know what you guys think.

My CSS:

#body              {
                        background-image: url(my image url);
                        background-attachment: fixed; 
                       }

1) I noticed that the image only fills in 3/4's of the page so what I did was put a few <br />'s so it would fill the page and walaa!! Is this bad practice? Would it work across different browsers?

2) Also, my image is 1024 x 731. How do I compress it and still have the same look, quality and the way it is viewed on the page?

3) I found that I like the look of some of the images that are oversized (meaning that only a portion of it is showing). Is there a way I can keep this look while compressing the image?

At your convenience,

Erek

Hi Erek,

Why would you have line breaks to position an image? Just use something along these lines;

#body {
background: url(my image url) center center fixed;
/*Other possible values include: top,right,bottom and left*/
}

That's the biggest issue with using lage images as backgrounds, use a photo editing application to find out what format and output quality sorts your purpose best.

As for your last question, if you just like that portion of the image showing, crop it accordingly and position it where you like it to be displayed.

All the best,

commented: Very helpful and understanding to newcomers +1

Magneato, thanks for the tip and your patience, I will try this out. I will crop the image and size it accordingly and see how this works.

(Previously, I used the line break to lower the image to the bottom of the page, if I didn't it would show some white space at the bottom instead.)

The image format for my background is a jpg. from psdrockstar.com.

I did what you said by adding the followind in my css: background: url(../../images/b2.jpg) center center fixed; I cannot, however, spread the image across the page for some reason. Also, what is a good height and width for a background image in the css?

Hi Erek,

Why would you have line breaks to position an image? Just use something along these lines;

#body {
background: url(my image url) center center fixed;
/*Other possible values include: top,right,bottom and left*/
}

I used the background: url() center center fixed;
I now need to spread the image from the center to the edges of the website (webpage). Is there an easy way to do this?

Erek

James this is great! I will implement this into my site.
Thanks a lot!!!
Erek

Glad to help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.