Old 12-01-2006, 05:32   #1 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
CSS image overlay

i just stumped myself...

if you go to http://www.kdwebserver.co.uk/~peartr...tree-sales.htm you'll see the images of the cameras at the bottom have a little green arrow (its part of the image).

What I want to do is create two graphics containing that arrow graphic (over and normal state) and then overlay the small arrow graphics using css on the actual graphic (which will save on download times)

i cant use background image for the a tag as obviously that will be hidden behind the graphic, im stuck, so please help
  Reply With Quote
Old 12-01-2006, 05:56   #2 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
actually, figured it out myself:

Code:
<div class="inline_images"> <a href="sales-aptus-75.htm"><img src="images/sales/aptus-75.jpg" alt="Aptus 75 Camera" width="147" height="148" border="0" title="Aptus 75 Camera" /> <span>fdsadf</span></a> </div> .inline_images { position: relative; width: 147px; height: 148px; } .inline_images span { position: absolute; top: 0px; left: 0px; width: 147px; height: 148px; background-image:url(../images/img_up.gif); background-repeat:no-repeat; } .inline_images span:hover { background-image:url(../images/img_over.gif); }
  Reply With Quote
Old 12-01-2006, 05:59   #3 (permalink)
pgo
i'm done, son
 
Join Date: Jan 2005
Posts: 12,262
The images are 5K...why not just do a rollover? As in...

<a href="#">Some Camera</a>

Use image replacement to get rid of the text, set the <a> as a block the size of the image, use a double sized image (both states in one image), on hover change the background-position. Problem solved with less markup and better accessibility.
  Reply With Quote
Old 12-01-2006, 06:10   #4 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
that method means that for each image it has to be made twice.. they may only be 5kb, but if you have 15 on a page:

5k x 15 = 75kb
75k * 2 = 150kb

this method ive just made now only comes to

5k * 15kb = 75kb
2kb total for mouseover graphics

77kb total....

and as the number of products continues to increase the size differences will start to become more noticeable - plus it will save time on the graphic creation side
  Reply With Quote
Old 12-01-2006, 06:22   #5 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
hrm, it works in FF but not IE.. any suggestions?

http://www.kdwebserver.co.uk/~peartr...tree-sales.htm
  Reply With Quote
Old 12-01-2006, 07:04   #6 (permalink)
iamtoby
Registered User
 
Join Date: Dec 2005
Location: London, UK
Posts: 11
IE doesn't support the use of :hover on any other element apart from the a tag.
  Reply With Quote
Old 12-01-2006, 07:34   #7 (permalink)
emil
dt immigrant
 
emil's Avatar
 
Join Date: Nov 2004
Location: Bucharest - Romania
Posts: 6,827
Send a message via ICQ to emil Send a message via MSN to emil Send a message via Yahoo to emil Send a message via Skype™ to emil
  Reply With Quote
Old 12-01-2006, 08:43   #8 (permalink)
stickmus
hmmm...
 
stickmus's Avatar
 
Join Date: Jan 2004
Location: Yorkuk
Posts: 2,130
You shouldn't need to script it, just change

.inline_images span:hover {

to

.inline_images a:hover span {
  Reply With Quote
Old 12-01-2006, 10:59   #9 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
that works, cheers
  Reply With Quote
Old 12-01-2006, 11:20   #10 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
got another problem with IE on this site,

if you go to http://www.kdwebserver.co.uk/~peartr...ment-cambo.htm

the first grey box shows correctly, but the second one has all the text squished up (its just a copy and paste of the one above with different content, if i delete the first one the second one shows properly)
  Reply With Quote
Old 12-01-2006, 11:35   #11 (permalink)
jthomas
coffee is not a crime
 
jthomas's Avatar
 
Join Date: Oct 2005
Location: Illinois, USA
Posts: 456
Hmm. That is wierd. Especially since IE 5.0 and 5.5 display it ok...just not 6. Any reason you are unable to use Strict instead of Transitional? Can we see styles?
  Reply With Quote
Old 12-01-2006, 12:23   #12 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
stupid IE!!!!

i need to find a fix
  Reply With Quote
Old 12-01-2006, 13:01   #13 (permalink)
finbarr
what a pile of dogshit?
 
finbarr's Avatar
 
Join Date: Apr 2005
Location: london
Posts: 2,449
Send a message via MSN to finbarr Send a message via Skype™ to finbarr
may not have anything to do with the probelm but whats the extra span for at the bottom of those divs?

</ul></span> <span></span> </div>
  Reply With Quote
Old 12-01-2006, 17:19   #14 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
that spans spare at the moment, an image is going to go in there
  Reply With Quote
Old 13-01-2006, 02:49   #15 (permalink)
emil
dt immigrant
 
emil's Avatar
 
Join Date: Nov 2004
Location: Bucharest - Romania
Posts: 6,827
Send a message via ICQ to emil Send a message via MSN to emil Send a message via Yahoo to emil Send a message via Skype™ to emil
You have spans around uls. I think that's what's causing you the problem
Check the W3C validator, error 6
Quote:
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").


Way too many divs for a simple layout, IMHO.
Anyway, this seems to fix the problem. (If you reverse the order of the .inner divs you'll see the same thing happens to the one coming after the first, so that's why I suspect the spans.)
Code:
* html div.inner .middle span { padding: 10px; width: 150px; float: left; clear:right;} * html .inner h2 { margin: 0px; padding: 0px; width:500px;}
  Reply With Quote
Old 17-01-2006, 04:53   #16 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
that works, cheers

just a quick question though... why does it work?!
  Reply With Quote
Old 17-01-2006, 04:58   #17 (permalink)
emil
dt immigrant
 
emil's Avatar
 
Join Date: Nov 2004
Location: Bucharest - Romania
Posts: 6,827
Send a message via ICQ to emil Send a message via MSN to emil Send a message via Yahoo to emil Send a message via Skype™ to emil
I just gave the h2 a fixed width for IE, as it kept squishing it in the fixed width span.
Can't remember what the clear:right fixed
  Reply With Quote
Old 17-01-2006, 06:24   #18 (permalink)
stealthcow
knocking heads
 
stealthcow's Avatar
 
Join Date: Jul 2003
Location: London, UK
Posts: 1,905
ah, gotcha
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8