Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Background image cover entire background w/one image

Background image cover entire background w/one image

Views: 16,117

Results 1 to 20 of 44
20 May 2009, 2:57 AM
#1
oxicottin avatar

oxicottin

Zen Follower

Join Date:
Aug 2006
Location:
West Virginia
Posts:
320
Plugin Contributions:
0

Background image cover entire background w/one image

Hello, I cant figure out what CSS to use in my stylesheet under the body section to get a image to cover the entire background. I don't want 1 image "background-repeat:no-repeat" and I don't want several images using " background-repeat:repeat". What would I use to get the image to cover the background no matter what size?

Thanks!

20 May 2009, 5:13 AM
#2
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,604
Plugin Contributions:
0

Re: Background image cover entire background w/one image

As in, you want the image to stretch and shrink?

20 May 2009, 12:01 PM
#3
oxicottin avatar

oxicottin

Zen Follower

Join Date:
Aug 2006
Location:
West Virginia
Posts:
320
Plugin Contributions:
0

Re: Background image cover entire background w/one image

Stretch with different sized windows.

20 May 2009, 2:25 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Background image cover entire background w/one image

Unfortunately, that's not possible. Background images are the size they are (in pixels) and do not stretch.

20 May 2009, 8:22 PM
#5
oxicottin avatar

oxicottin

Zen Follower

Join Date:
Aug 2006
Location:
West Virginia
Posts:
320
Plugin Contributions:
0

Re: Background image cover entire background w/one image

I found some examples that it is working on websites but I don't know where to start?

Example 1

Example 2

Thanks!

20 May 2009, 9:44 PM
#6
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,604
Plugin Contributions:
0

Re: Background image cover entire background w/one image

Them implement the stuff in the tutorial ...

21 May 2009, 1:13 AM
#7
oxicottin avatar

oxicottin

Zen Follower

Join Date:
Aug 2006
Location:
West Virginia
Posts:
320
Plugin Contributions:
0

Re: Background image cover entire background w/one image

Ok, I got it to work somewhat. My image is on top of my web site instead of in the background But it stretches. Here is what I did....
I added a div in the body of my tpl_main_page.php```

<div id="bg"><img src="includes/templates/Primitive/images/TestImage.gif" width="100%" height="100%" alt=""></div> ``` and then I added ``` #bg {position:fixed; top:0; left:0; width:100%; height:100%; ```to my stylesheet.css. What am I doing wrong?
25 May 2009, 4:23 PM
#8
oxicottin avatar

oxicottin

Zen Follower

Join Date:
Aug 2006
Location:
West Virginia
Posts:
320
Plugin Contributions:
0

Re: Background image cover entire background w/one image

Any ideas? Thanks!

26 May 2009, 6:24 AM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Background image cover entire background w/one image

Any positioned element will display on top of non-positioned elements. You need to position the rest of the page content, the way the example does with the "content" div. You would probably want to make #mainWrapper position: relative; and z-index: 1; like the example.

You don't say where you added your new div; it needs to be outside of the #mainWrapper div.

19 Feb 2011, 4:00 AM
#10
lacktorium avatar

lacktorium

New Zenner

Join Date:
Feb 2011
Posts:
6
Plugin Contributions:
0

Re: Background image cover entire background w/one image

for any one that stumbles across this as i did, the css for it is now.

body {
	margin: 0;
	font-family: verdana, arial, helvetica, sans-serif;
	font-size: 65.5%;
	color: #000000;
	background-color: #e5edf5;
	background-image: url(../images/background.jpg);
	background-repeat: no-repeat;
	background-attachment: fixed;
	background-position: center top;
	background-clip: border-box;
	background-origin: padding-box;
	background-size: auto auto;
	}
20 Feb 2011, 5:50 PM
#11
dontblink7 avatar

dontblink7

New Zenner

Join Date:
Jan 2011
Posts:
53
Plugin Contributions:
0

Re: Background image cover entire background w/one image

lacktorium:

for any one that stumbles across this as i did, the css for it is now.

body {
margin: 0;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 65.5%;
color: #000000;
background-color: #e5edf5;
background-image: url(../images/background.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center top;
background-clip: border-box;
background-origin: padding-box;
background-size: auto auto;
}

thx for the code but i don;t get what they are saying up there about the <div>, any help?
20 Feb 2011, 8:07 PM
#12
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Background image cover entire background w/one image

You need to follow the instructions given on the site the example comes from (post 5). This means not making the "background" an actual CSS background-image, but an <img> in a new div.
I don't know what the recent style rule posting was about, as it would not make an image stretch to fit the window.

20 Feb 2011, 11:22 PM
#13
kaoschris avatar

kaoschris

New Zenner

Join Date:
Feb 2007
Location:
San Francisco, CA
Posts:
16
Plugin Contributions:
0

Re: Background image cover entire background w/one image

You can also put it after html and streamline the code by doing it this way```
html {
margin: 0;
padding: 0;
background: url(location_of_image.jpg) no-repeat center center fixed;

20 Feb 2011, 11:33 PM
#14
kaoschris avatar

kaoschris

New Zenner

Join Date:
Feb 2007
Location:
San Francisco, CA
Posts:
16
Plugin Contributions:
0

Re: Background image cover entire background w/one image

Here is a great tutorial. http://css-tricks.com/perfect-full-page-background-image/ You don't need to worry about div's just use that tutorial, and it should work no problem.

21 Feb 2011, 4:30 AM
#15
lacktorium avatar

lacktorium

New Zenner

Join Date:
Feb 2011
Posts:
6
Plugin Contributions:
0

Re: Background image cover entire background w/one image

KaosChris:

Here is a great tutorial. http://css-tricks.com/perfect-full-page-background-image/ You don't need to worry about div's just use that tutorial, and it should work no problem.

nice tutorial, like the JavaScript.

14 Jan 2012, 10:12 AM
#16
bumblewear avatar

bumblewear

New Zenner

Join Date:
Jan 2012
Posts:
2
Plugin Contributions:
0

Re: Background image cover entire background w/one image

:clap: fantastic help thank you

15 Jan 2012, 3:07 PM
#17
melissamiller8 avatar

melissamiller8

New Zenner

Join Date:
Jan 2011
Location:
Iowa
Posts:
87
Plugin Contributions:
0

Re: Background image cover entire background w/one image

My problems are always so fundamental: In the following:

background-image: url(../images/background.jpg);

What actually goes in the area before " /images..."

My site is at:

http://creativesimplicitywebdesign.com/shop/

and my background image is just in that directory, in no particular file folder. I'll call my background image "backer.jpg". what now?

16 Jan 2012, 6:00 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Background image cover entire background w/one image

You need to put your background image in /shop/includes/templates/your_template/images/backer.jpg.
Then the (../images/etc) will point exactly to the image location without further ado.

2 Feb 2012, 3:53 PM
#19
anjordan77 avatar

anjordan77

Zen Follower

Join Date:
Jun 2006
Location:
Midlothian, Virginia, United States
Posts:
110
Plugin Contributions:
0

Re: Background image cover entire background w/one image

This is how i got the background image to work in zencart 1.3.9h at my website All Paintball Supplies:

upload background image called background.jpg to: /yourshop/images

Then implement this code in your stylesheet.css for me found /yourshop/includes/templates/classic/css/ right before the current body:

body {
margin: 0;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 65.5%;
color: #000000;
background-color: #e5edf5;
background-image: url(../images/background.jpg);
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center top;
background-clip: border-box;
background-origin: padding-box;
background-size: auto auto;
}

NEXT, you need to comment out your current body code like this:

/*body {
margin: 0;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 62.5%;
color: #000000;
background-color: #e5edf5;
}

*/

2 Feb 2012, 3:55 PM
#20
anjordan77 avatar

anjordan77

Zen Follower

Join Date:
Jun 2006
Location:
Midlothian, Virginia, United States
Posts:
110
Plugin Contributions:
0

Re: Background image cover entire background w/one image

Next all i need to do is make an image that fills in the left and right sides with what i actually want people to see and isn't 4megs big...lol

If anyone can figure out how to have this image span across the header and footer that would be splendiforous!