I have a site that I'm working on where the products are going to be generated dynamically using php. I want each one to have a green border around it with rounded corners, and then when you rollover it, I want it to change the border color to orange. We have all the product images with a white background, and there are too many to actually add the border to the photo. So, we need to wrap the pictures with a colored border and rounded corners somehow and get them to change on rollover.
Make a class attach it to A tag assuming the size of the thumb will stay the same. something like that .product-thumb { display:block; width:100px; height:100px; } .product-thumb a:active, a:visited{ background:url(border1.gif) no-repeat; } .product-thumb a:hover{ background:url(border2.gif) no-repeat; }
No, unfortunately the images are not always the same size. I am able to make the width the same, but the length would change. However, I was thinking there must be a way to put the border in the foreground and the image in the background using the border as a mask for the images, and then changing the border on rollover. So, you would only see the top portion of the images that are longer and then when you click on it you'd get the product page with the large image and description etc. I'm still fairly new to css and php though and didn't know if it's possible to make that happen dynamically, and if so, how?
Or you could combine the two top images and two bottom images into 1 image for the bottom and 1 for the top and shift the position, using the CSS sprite technique.
Not saying this code will work exactly when you plug it in, depends on how big some of the images are, and so forth.
I'm trying out your solution and I think that I misunderstood your origional now that I'm getting into it. I'm not following what your suggesting. Can you explain the 2 hovers? I am working with 3 images right now (product.jpg, green-border.gif, orange-border.gif). Are you suggesting handling it differently?
I've seen the shift method your talking about, but I with what I'm working with it would be one image instead of 2 (green-border.gif + orange-border.gif = border.gif) So, I'm not sure what the other images are.
Could you place my images in the code in the proper place and explain a little bit more about what you are doing? Thanks again!
Ok. I think I'm seeing what you are doing now. It seems like you are using the top border bars and bottom border bars as the four images. That would allow for images of different sizes. However, what we would like to do is to keep them all the same size although the product images are different sizes.
Is there a way to use a gif that has the border with a hole in the middle to mask off the image. It would be nice to be able to do that for the green and orange borders, and then put them in front of the product image somehow to mask it off so they are all the same size.
I updated the page that I linked to above with something that is very close to working the way I want it to. It works in firefox perfectly; however, in internet explorer 6 & 7 the link doesn't work. I made the first box link to google. the others do not actually link to a site.
In IE6 it doesnt work because you are using the hover state on the div. Hover in IE6 only works on anchor tags. You don't need those extra divs though, you can attach one of the backgrounds to the anchor, and the other to the image.
Ok. I updated the link again. I removed one of the divs and just used the anchor as you suggested, and that did fix the problem with the link not working. Thanks for that one!
Any ideas why the images won't go to the back in ie 6 and 7. The middle one is staying in front of the border.
Originally, we were thinking that we wanted them different heights, but we decided that it would look a lot cleaner to have them be the same size. We are going to have several rows of products and having a few big ones will throw things off and it will look messy.
Is there any other way we can handle the z-index issue or is there something that would do the same thing?
The product images aren't the same size, and they are coming from a database with a couple hundred images. There aren't just a couple images, so resizing them all to be the same height is unrealistic for us.
Is there any other way we can handle the z-index issue or is there something that would do the same thing?
I think the image may be sitting on top of the link, and covering up the middle hotspot. For whatever reason firefox still finds it, but of course IE can't. Will I need to link the image also to get that to work?
IE is still giving me problems. I still can't click the image and go on to the next page. I have to click the border to get there. I tried adding another anchor tag around the image, but that through everything off. So, if this is the last problem. Any more ideas?