New Landing How can we help? Cardinal Black & White to Color

Viewing 7 posts - 1 through 7 (of 7 total)
  • Posted in: Cardinal
  • #306666
    dominicktmg
    Member
    Post count: 7

    Is there a way to make it so that an image displays as black and white and changes to color when a user hovers over it?

    #306668
    HiroiSekai
    Member
    Post count: 144

    If you want to affect all images on the site (this will include things like header images, logos and so on), then add the following CSS:

    img {
    filter: grayscale(100%); /* Standard CSS */
    -webkit-filter: grayscale(100%); /* CSS for Webkit Browsers */
    filter: url(/elements/grayscale.svg#desaturate); /* Firefox 4-34 */
    filter: gray; /* Internet Explorer IE6-9 */
    -webkit-filter: grayscale(1); /* Old WebKit Browsers */
    }

    img:hover {
    filter: grayscale(0%);
    filter: none;
    -webkit-filter: grayscale(0); /* Old WebKit */
    }

    If you want to target specific images, give them a unique class in the page builder and target those using the same code.

    #306670
    dominicktmg
    Member
    Post count: 7

    Awesome! Could you give me an example of how I would target specific images?

    #306689
    HiroiSekai
    Member
    Post count: 144

    Sure, if you’re using the Text view on the editor, give your image an ID if it’s just one image, or give it a class if it’s a group of similarly occurring images. Example:

    Normal image insert
    <img src="http://imgur.com/something.jpg" />

    Image insert with ID
    <img id="myImage" src="http://imgur.com/something.jpg" />

    Image insert with class
    <img class="myImages" src="http://imgur.com/something.jpg" />

    If using the Visual view, just click on the image, click on the edit pencil and change the name in the Image CSS Class field. In your CSS,

    Target ID names with:

    #myImage {
    filter: grayscale(100%); /* Standard CSS */
    -webkit-filter: grayscale(100%); /* CSS for Webkit Browsers */
    filter: url(/elements/grayscale.svg#desaturate); /* Firefox 4-34 */
    filter: gray; /* Internet Explorer IE6-9 */
    -webkit-filter: grayscale(1); /* Old WebKit Browsers */
    }

    #myImage:hover {
    filter: grayscale(0%);
    filter: none;
    -webkit-filter: grayscale(0); /* Old WebKit */
    }

    If it’s a class, just change the # to a . symbol. Remember, ID’s are for single-case objects and classes are for reoccurring things. Like if you’re wanting to do this for a header image in every single post you do, use a class. If it’s a single photo on a certain post, use an ID.

    #306697
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    @HiroiSekai
    Thanks for sharing.

    -Rui

    #306986
    dominicktmg
    Member
    Post count: 7

    You rock. Thank you!

    #306987
    David Martin – Support
    Moderator
    Post count: 20834

    Thanks guys, marking as resolved.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register