2010-07-02 3 views

답변

5

대안은 CSS 전환-duration 속성 수 있습니다. 이렇게하면 지정된 시간 동안 단색이 유지되지 않지만 예를 들어 한 색상에서 다른 색상으로 전환 할 때 초 단위가 소요될 수 있습니다. 이것은 페이지를 방문하는 일부 브라우저에서 지원되지 않을 수 있으므로 jQuery를 사용하여 다른 답변을 작성하는 것이 좋습니다.

a { 
    color: red; 
    transition-duration: 5s; 
    -moz-transition-duration: 5s; 
    -webkit-transition-duration: 5s; 
} 

a:hover { 
    color: blue; 
} 
+0

예, 그게 그렇게 중요하지 않아요. FF와 Chrome에서 잘 작동합니다. – thegreyspot

4

확실!

$('#myLinkId').hover(
    function(e){ 
    //mouseover 
    $(this).css('color','blue'); 
    }, 
    function(e){ 
    //mouseout 
    $(this).animate({color:'black'},300); //300 is the speed of the animation in ms 
    } 
); 

애니메이션 문서 : http://api.jquery.com/animate/

+2

색상을 움직이게하려면 jQuery UI가 필요합니다. – sje397

+0

좋은 지적, 감사합니다! 나는 대답 할 때 메모를 할 것이다. –

+1

간단한 작업을 위해 다른 플러그인을 사용 하시겠습니까? 정말이 jQuery UI가 필요하다고 생각 ... – Reigel

4

demo

CSS

a { 
    color: red; 
} 

a.blue { 
    color: blue; 
} 

HTML이 링크가 페이드 아웃하려는 경우, 당신은 색상을 애니메이션 jQuery를 UI가 필요합니다

<a href="index.html">home</a> 

jQuery를이

$(document).ready(function(){ 
    $('a').hover(function(){ 
     $(this).addClass('blue'); 
    }, 
    function(){ 
     var link = $(this); 
     setTimeout(function(){link.removeClass('blue');},1000); 
    }) 
}) 

demo

+0

Very 이걸 사용하겠습니다. – Pierreten

+0

1000ms 후에 다시 전환하는 대신 어떤 방법으로 페이드 아웃 할 수 있습니까? (미안하지만 질문에 언급하지 않았습니다) – thegreyspot

+0

@thegreyspot - 그럴 경우 Jon Weers 대답을 사용하십시오. – Reigel

관련 문제