Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorjay0316
    • CommentTimeAug 24th 2007
     permalink
    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.

    Here is an image I put together in photoshop of the products in their normal state and one in a rollover state. http://www.coastalpet.com/rollover.jpg

    I think it will be easy to do with square corners, but the rounded corners are making it difficult.

    Do you know how I could make this work?

    Thanks!
  1.  permalink
    Easy!

    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;
    }

    DS
    • CommentAuthordavist11
    • CommentTimeAug 24th 2007
     permalink
    Yeah, I mean the big question is: will the thumbnails will always be the same size?
    • CommentAuthorjay0316
    • CommentTimeAug 27th 2007 edited
     permalink
    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?
    • CommentAuthordavist11
    • CommentTimeAug 27th 2007
     permalink
    Could do something like this:

    <a href="#" class="imgWrapper"><img src="whatever.jpg" /></a>

    a.imgWrapper {
    background: url(top-image-bg.gif) no-repeat 0 0;
    padding-top: 10px; /*However tall the top portion of the image is*/
    }

    a.imgWrapper img {
    background: #F1763B url(bottom-image-bg.gif) no-repeat 0 100%;
    padding-bottom: 10px; /*however tall the bottom portion of the image is*/
    }

    a.imgWrapper:hover {
    background: url(top-image-hover-bg.gif) no-repeat 0 0;
    }

    a.imgWrapper:hover img {
    background: #395932 url(bottom-image-hover-bg.gif) no-repeat 0 100%;
    }

    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.
    • CommentAuthorjay0316
    • CommentTimeAug 27th 2007
     permalink
    Thanks davist11,

    That sounds like a good solution! I am going to work with that a bit and see if it will solve my problem. I will post back if I run into any issues.
    • CommentAuthorjay0316
    • CommentTimeAug 29th 2007
     permalink
    davist11,

    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!
    • CommentAuthordavist11
    • CommentTimeAug 29th 2007
     permalink
    jay0316,
    do you have a page to look at? it can really help to explain it better.
    • CommentAuthorjay0316
    • CommentTimeAug 29th 2007 edited
     permalink
    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.

    Thanks!
    • CommentAuthorjay0316
    • CommentTimeAug 29th 2007
     permalink
    Here is an attempt I had made using a div tag and the a tag. I couldn't get the product image to go behind the rollover. http://www.coastalpet.com/remington/font-test.html
    • CommentAuthorjay0316
    • CommentTimeAug 29th 2007
     permalink
    davist11,

    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.

    Is there a way to make this work with IE?
    • CommentAuthorjay0316
    • CommentTimeAug 29th 2007
     permalink
    i just noticed that the roll overs don't work in ie6 either.

    any suggestions?
    • CommentAuthordavist11
    • CommentTimeAug 29th 2007
     permalink
    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.
    • CommentAuthorjay0316
    • CommentTimeAug 29th 2007
     permalink
    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.
    • CommentAuthordavist11
    • CommentTimeAug 29th 2007
     permalink
    Because z-index in IE sucks. I thought you wanted them to be able to be different heights?
    • CommentAuthordavist11
    • CommentTimeAug 29th 2007
     permalink
    • CommentAuthorjay0316
    • CommentTimeAug 29th 2007
     permalink
    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?
    • CommentAuthordavist11
    • CommentTimeAug 29th 2007
     permalink
    Why not just take the code that I did and have the actual images the same height?
    That way the images can be in source and not in the CSS too.
    • CommentAuthorjay0316
    • CommentTimeAug 30th 2007
     permalink
    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?

    Thanks!
    • CommentAuthordavist11
    • CommentTimeAug 30th 2007
     permalink
    • CommentAuthorjay0316
    • CommentTimeAug 30th 2007
     permalink
    Thanks again davist!

    Only one problem left. In IE 6 & 7 I can only get to google if I click the outside border. It won't let me click the product image and get there.
    • CommentAuthorjay0316
    • CommentTimeAug 30th 2007
     permalink
    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?

    Thanks.
    • CommentAuthorjay0316
    • CommentTimeSep 6th 2007
     permalink
    Here is where I'm at with this right now. http://www.coastalpet.com/remington/product_results.php?search=301

    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?

    Thanks!
    • CommentAuthorjay0316
    • CommentTimeSep 7th 2007
     permalink
    I solved this problem by adding onClick="parent.location="http://item address" to the image tag. It works great now in both IE and Firefox!
Add your comments
    Username Password
  • Format comments as (Help)