Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / how do I add images using absolute positioning?

how do I add images using absolute positioning?

Views: 1,788

Results 1 to 20 of 22
5 Sep 2011, 11:03 PM
#1
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

how do I add images using absolute positioning?

Hi, I've done this on other sites before but I cant seem to get it to work on this one. Here is what I was trying for a test to see where it is and adjust but nothing shows.

#sticky {
	background-image: url(../images/sticky.png);
	position:absolute;
	left:168px;
	top:143px;
	}
6 Sep 2011, 12:58 AM
#2
rstevenson avatar

rstevenson

Totally Zenned

Join Date:
Nov 2006
Location:
Dartmouth, NS Canada
Posts:
2,400
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Sorry, but I have to ask. Is sticky.png in the images folder in your template's folder? Or is it in the main images folder? Your style refers to the former location.

Also, just as a test, make the image a jpg and see if it works. (You never know.)

Rob

6 Sep 2011, 1:37 AM
#3
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

I changed them to jpg and I uploaded it to both folders and also changed the css to reflect the jpg. Still nothing.

6 Sep 2011, 5:26 AM
#4
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: how do I add images using absolute positioning?

This piece of code seems to be okay, but maybe you8 made an error in the code before #sticky. See is you can find any missing brackets or semicolons.

6 Sep 2011, 5:42 AM
#5
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

I checked and no missing brackets or semicolons.

Just to make sure though, when using this code it should show the image on top of anything else in the page, right? I mean it isn't hiding under another image or anything.

Also I shouldn't have to put anything on the page it should just show because the css says it is supposed to. right?

I've changed the numbers around as well as the images and I can't ever get anything to show. I have the code added to the index_home.css at the bottom. Should the placement make a difference. I have also tried this on the stylesheet.css and still nothing on the other pages as well.

6 Sep 2011, 6:10 AM
#6
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: how do I add images using absolute positioning?

ScottDB:

I checked and no missing brackets or semicolons.

Just to make sure though, when using this code it should show the image on top of anything else in the page, right? I mean it isn't hiding under another image or anything.

Also I shouldn't have to put anything on the page it should just show because the css says it is supposed to. right?

I've changed the numbers around as well as the images and I can't ever get anything to show. I have the code added to the index_home.css at the bottom. Should the placement make a difference. I have also tried this on the stylesheet.css and still nothing on the other pages as well.

I is possible it is "hiding" underneath something else. what happens if you add a z-index to it?

6 Sep 2011, 10:51 AM
#7
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Don't know what you mean by a z index to it. Never seen that one before. Can you show me the code to add?

6 Sep 2011, 11:14 AM
#8
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: how do I add images using absolute positioning?

#sticky {
	background-image: url(../images/sticky.png);
	position:absolute;
	left:168px;
	top:143px;
	z-index:5;
	}
6 Sep 2011, 11:32 AM
#9
gjh42 avatar

gjh42

Black Belt

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

Re: how do I add images using absolute positioning?

What element has the #sticky id? I don't see it in your homepage view source. Does it have something else in it beside the background-image? If not, there will be nothing to give it size and you will not be able to see it.

7 Sep 2011, 1:54 AM
#10
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Oh ya, sorry about that. I took it out when doing some more editing figuring that it wasn't working anyway. I was trying to put in the define page editor for main page. I take it that is not where it should go. :P Not sure where to put it or if I got it right.

Here is what I am trying to use.

<div class="sticky">
7 Sep 2011, 2:11 AM
#11
gjh42 avatar

gjh42

Black Belt

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

Re: how do I add images using absolute positioning?

That should work, as long as there is something inside the div to give it size. What is the entire div content you had? Can you put it back so I can take a look?

7 Sep 2011, 2:19 AM
#12
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Well that's probably what is wrong then since I just barely understand how this works. Kind of a newbie.

That was the entire content of the div. I just added that to the end of the define page editor/ index page just like that. Just the css code that I had shown and the <div class="sticky"> in the page

7 Sep 2011, 2:44 AM
#13
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,799
Plugin Contributions:
15

Re: how do I add images using absolute positioning?

You have nothing in the sticky or in the stylesheet.:dontgetit

Except for 16 <br> tags!

7 Sep 2011, 3:14 AM
#14
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Well I just checked and all the way at the bottom of the index_home.css I have the code that I posted above

#sticky {
	background-image: url(../images/sticky.png);
	position:absolute;
	left:168px;
	top:143px;
	}

In the define main page I have towards the top of all those </br>'s the <div class="sticky"> and oh dang. I just realized that even though I don't know what you mean I should be putting into the sticky I don't even have an end </div>

7 Sep 2011, 3:19 AM
#15
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,799
Plugin Contributions:
15

Re: how do I add images using absolute positioning?

That will not load.
Should be in stylesheet.css or something like stylesheet_home.css or it won't load.

7 Sep 2011, 3:39 AM
#16
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Ok I'll try and rename the template but that is what was told to me to do in another post and it seems to be working for everything else.

7 Sep 2011, 3:50 AM
#17
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,799
Plugin Contributions:
15

Re: how do I add images using absolute positioning?

The index_home.css and the regular stylesheet.css (neither is a template) are butting heads and if you use firebug you'll see that the background image never shows up.
You might try the .jpg fix mentioned earlier. If you are using png for transparency, it just doesn't work well enough to try.:no:

7 Sep 2011, 4:02 AM
#18
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Sorry, Mistake on wording. I meant change the name of the stlyesheet index_home.css. I did rename the image to jpg and in the css as well just now. Did it earlier but when I added it back in later I forgot to change it again.

The reason that the stylesheets are butting heads are probably because I didn't do what was suggested and just add the edits I made to the original stylesheet. I just used the whole stylesheet and renamed it. I was planning on going through that later and deleting all the stuff that wasn't changed out of the index_home.css

10 Sep 2011, 3:03 PM
#19
gjh42 avatar

gjh42

Black Belt

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

Re: how do I add images using absolute positioning?

<div class="sticky">

#sticky {

# is the symbol for an id, not a class. You need to either change that to . or change class= to id=.

.sticky {

10 Sep 2011, 6:22 PM
#20
scottdb avatar

scottdb

New Zenner

Join Date:
Jul 2011
Posts:
95
Plugin Contributions:
0

Re: how do I add images using absolute positioning?

Thanks for the info. I tried it again with no luck. I knew that the two were different but didn't know which one was for what. I tried it with both id and class and nothing shows. I even tried them both with different left and top coordinates. Here is what I am using

.sticky {
	background: url(../images/sticky.jpg);
	position:absolute;
	left:168px;
	top:43px;
	}

With this I am using <div class="sticky"></div>