Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2011
    Posts
    30
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Changing Image Color

    Hi there,

    can anyone help with a code to change an image from one color to the next? I have the two images. The first is black the second is white. I want the black one to be always showing but when you put your mouse over the image it changes to the white one. I think its called hover over or something like that?

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,925
    Thanks
    46
    Thanked 203 Times in 202 Posts
    :hover
    so if you have two classes
    .blah
    .hah
    you can do .blah:hover .hah{}
    *note my syntax may be skewed bc im spoiled and VS fixes it for me

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #3
    Regular Coder
    Join Date
    Mar 2010
    Location
    Orlando, FL
    Posts
    161
    Thanks
    4
    Thanked 8 Times in 8 Posts
    If you give your image a class, like class="image1", then the css code would be image.image1:hover {background-image: url("images/image2.png");}

    This is the only way I know how to do it off the top of my head. For hover effects I usually put image1 in a div and then give that div a background-image of image1. This is so I can easily have the hover effect I just showed you.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •