Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    7
    Member #
    36159
    So I'm trying to learn HTML/CSS to hand code my updated design portfolio (mainly a print designer). At this point, I'm trying to stick with just HTML/CSS--I don't want to use JS/jQ since I haven't even scratched that surface. I'm an in-house designer and this is intended to get some freelance work and to have a place to show my work to employers work new jobs in the future.

    My site is going to be set up as a grid of thumbnail images in the main content, 3 across, all the same size (440x440 px). This is intended for large monitors, +1350 px. I plan to scale down the images and/or reduce the layout to 2 across using media queries as browser size decreases.

    What I'm looking for is help with the thumbnail images...ideally, I'd like them all to be grayscale, with a smooth 1 sec transition to full color on rollover. I was successful in implementing this using CSS Sprites and a transition, which required an empty <span> inside the <a> tag. However, since these thumbs are the essential part of my site, I'm not sure it's smart to do this without <img> tags in the HTML, as using sprites/background-image carry no semantic meaning, correct?

    Someone suggested using <img> tags and using a filter: grayscale effect in my CSS, which worked ok, but it's only supported by Chrome currently.

    Does anyone have a solution to this, without using javascript? What about opinions on only using background-images in my CSS and neglecting <img> tags altogether.

  2.  

  3. #2
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    You could theoretically handle it by having an img tag inside of your a tag containing the full color image, then on rollover have your transition.
    Code:
    a img {opacity: 0;}
    a:hover img {opacity:  1;} /* I haven't messed with CSS transitions */
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  4. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    7
    Member #
    36159
    where would the grayscale image go though? I want it to roll from grayscale to color. If I'm understanding media queries correctly, you load different CSS styles depending on browser size, so any changes to the layout have to be contained there, which is why I initially used CSS sprites so everything was contained in an external CSS style sheet...only the basic tags in HTML.

  5. #4
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    You could do it one of two ways that I can think of:

    1) Make the greyscale image the background of the a tag.
    2) Create a second image tag that houses the greyscale image. You'd have to use absolute positioning and z-index to pull off the effect you want, so I wouldn't recommend going this route without experience, but if you can it would be the optimal route simply because you now have two images that could potentially be indexed and found using image searches instead of one.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  6. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    7
    Member #
    36159
    Ok, so would you use opacity values for the color image inside the <img> tag, set initially to 0 and on rollover changing to 1?

    **********************

    <a id="image-1" href="URL">
    <img class="color-image" src="image-source" alt="alt text" title="title text"/>
    </a>

    #image-1 {
    width: 200px;
    height: 200px;
    background-image: url(grayscale-image.jpg) no-repeat;
    }

    .color-image {
    width: 200px;
    height: 200px;
    opacity: 0;
    }

    .color-image:hover {
    opacity: 1;
    }

    ***********************

  7. #6
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    That would be how I'd start, yes. How I'd end would depend on what I saw when I started.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  8. #7
    Junior Member
    Join Date
    Apr 2013
    Posts
    7
    Member #
    36159
    I tested this and the rollover to color part worked fine, but the grayscale image (set up as a background in CSS for the <a> tag) wasn't showing up at all...it was just blank and then it transitioned into the color image.

    Is the place of either the <a> or <img> tags where I'm going wrong?

    <div>
    <a class="gray" href="URL">
    <img class="color" src="image-source" alt="alt text" title="title text"/>
    </a>
    </div>

    I then just set up another image for the grayscale before the color one, and then I got what I wanted.

    <div>
    <a href="URL">
    <img class="gray" src="image-source" alt="alt text" title="title text"/>
    <img class="color" src="image-source" alt="alt text" title="title text"/>
    </a>
    </div>

    Seems like this might cause slower load issues? I guess right now the image files are around 30-40k, which will be par for the course throughout the homepage of the site. Any easier solution, or can you think of what went wrong with the first method?

  9. #8
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Your load times will be identical, since either way you have to call up a grayscale and a color image.

    Like I said, option 2 was the better of the two options in my mind just because of the image search implications, although I would have thought it would be more difficult to get working (apparently you had the opposite experience). So I'd do it the way it works.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:52 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com