Skip to main content

Is there a better way of achieving this effect?



I have an image thumbnail with a light colored border which, on mouseover, I want to crossfade to a dark colored border. I'm thinking that the easiest way to achieve this would be to fade in a second div with a darker border over the existing one.





Is there a better or different way to fade in a border color change?





Thanks.


Comments

  1. Load the jQuery UI into your page. Included with the core package (if I'm not mistaken; you may need to customize your download package) is the ability to use jQuery's .animate() on color values (and/or transitions between two CSS classes). This is something absent from the core jQuery library out-of-the-box.

    With that, you can just do something as menial as the following:

    // e.g. assuming #foo has default border-color #999999
    $('#foo').on('mouseover', function () {
    $(this).animate({
    borderColor : "#333333"
    });
    });


    Modify according to your interests.

    ReplyDelete
  2. There are many ways.

    One is through CSS3 transitions. Although not working in IE, you can have it progressively enhanced to modern browsers.

    assuming your div has a class of imageBorder:

    div.imageborder {border-color: #FFFFFF;}
    div.imageBorder:hover {
    border-color: #FF0000;
    -webkit-transition: all 1s ease-in-out;
    -moz-transition: all 1s ease-in-out;
    -o-transition: all 1s ease-in-out;
    -ms-transition: all 1s ease-in-out;
    transition: all 1s ease-in-out;
    }


    The other way is to use javascript, Here is a jQuery sample:

    $('div.imageBorder').hover(
    function(){
    $(this).animate({
    border-color: '#FF0000',
    },200,function(){});
    },
    function(){
    $(this).animate({
    border-color: '#FFFFFF',
    },200,function(){});
    }
    );


    This will work in IE as well, but at the cost of loading an extra library.

    ReplyDelete
  3. Put your thumbnail inside a DIV with light colored border (default), later on mouseover find the div and change the style (border-width and border-color), although it is not a fadding style but as user quickly mouseover and mouseout on the image looks like minor fadding effect that is enough i guess. Write your own javascript code to make it faster (jQuery surely gets more time javascript code) .

    ReplyDelete
  4. Can you apply a CSS3 transition on the border color?

    ReplyDelete

Post a Comment

Popular posts from this blog

Slow Android emulator

I have a 2.67 GHz Celeron processor, 1.21 GB of RAM on a x86 Windows XP Professional machine. My understanding is that the Android emulator should start fairly quickly on such a machine, but for me it does not. I have followed all instructions in setting up the IDE, SDKs, JDKs and such and have had some success in staring the emulator quickly but is very particulary. How can I, if possible, fix this problem?

CCNA 1 Final Exam 2011 latest (hot hot hot)

  Hi! I have been posted content of ccna1 final exam (latest and only question.) I will post the answer and insert image on sunday. If you care, please subscribe your email an become a first person have full test content. Subcribe now  Some question  have not content because this question have images content. So that can you wait for me? SUNDAY 1. A user sees the command prompt: Router(config-if)# . What task can be performed at this mode? Reload the device. Perform basic tests. Configure individual interfaces. Configure individual terminal lines. 2. Refer to the exhibit. Host A attempts to establish a TCP/IP session with host C. During this attempt, a frame was captured with the source MAC address 0050.7320.D632 and the destination MAC address 0030.8517.44C4. The packet inside the captured frame has an IP source address 192.168.7.5, and the destination IP address is 192.168.219.24. At which point in the network was this packet captured? leaving host A leaving ATL leaving...