使用jquery选择器触发的css悬停效果?

时间:2014-03-27 05:50:12

标签: jquery overlay selector intervals

尝试为徽标添加“微光”效果。使用css完成了它,但是想用js interval和jquery选择器每隔10秒左右添加一次效果。我可以触发:悬停效果吗?到目前为止我无法解决这个问题。有什么帮助吗?

http://jsfiddle.net/AzGfs/

w ^

 var shimmer = $('.shimmer'),
    c = 0;

function loop() {
    shimmer.removeClass('shimmer-hover').eq(c++ % shimmer.length).addClass('shimmer-hover');
}
loop();
setInterval(loop, 10000);

    header img {
    width:99% !important;
    height:99% !important;
}
.shimmer {
    display: block;
    position: relative;
    overflow: hidden;
    border:0px;
}
.shimmer .shimmer-effect {
    position: absolute;
    top: -110%;
    left: -210%;
    width: 200%;
    height: 200%;
    opacity: 0;
    border:0px;
    background: rgba(255, 255, 255, 0.2);
    background: -moz-linear-gradient(left, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0.0) 100%);
    background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0.0) 100%);
    background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0.2)), color-stop(75%, rgba(255, 255, 255, 0.2)), color-stop(90%, rgba(255, 255, 255, 0.8)), color-stop(100%, rgba(255, 255, 255, 0.0)));
    background: -o-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0.0) 100%);
    background: -ms-linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, 6 rgba(255, 255, 255, 0.0) 100%);
    background: linear-gradient(top, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 75%, rgba(255, 255, 255, 0.5) 90%, rgba(255, 255, 255, 0.0) 100%);
    -webkit-transform: rotate(30deg);
    -moz-transform: rotate(30deg);
    -ms-transform: rotate(30deg);
    -o-transform: rotate(30deg);
    transform: rotate(30deg);
    -webkit-transition-property: left, top, opacity;
    -moz-transition-property: left, top, opacity;
    -ms-transition-property: left, top, opacity;
    -o-transition-property: left, top, opacity;
    transition-property: left, top, opacity;
    -webkit-transition-duration: 0.5s, 0.5s, 0.1s;
    -moz-transition-duration: 0.5s, 0.5s, 0.1s;
    -ms-transition-duration: 0.5s, 0.5s, 0.1s;
    -o-transition-duration: 0.5s, 0.5s, 0.1s;
    transition-duration: 0.5s, 0.5s, 0.1s;
    -webkit-transition-timing-function: ease;
    -moz-transition-timing-function: ease;
    -ms-transition-timing-function: ease;
    -o-transition-timing-function: ease;
    transition-timing-function: ease;
}
/* Hover state - trigger effect */
 .shimmer:hover .shimmer-effect {
    opacity: 1;
    top: -30%;
    left: -30%;
    border:0px;
}
/* Active state */
 .shimmer:active .shimmer-effect {
    opacity: 0;
    border:0px;
}
/* sim hover state */
 .shimmer-hover .shimmer-effect-hover {
    opacity: 1;
    top: -30%;
    left: -30%;
    border:0px;
}

    <div class="content-header"> <a class="shimmer" id="shimmer" href="javascript:;"><span class="shimmer-effect"></span><img id="header" src="http://designstexas.com/logo.jpg" width="692" height="162" alt=""></a> 
</div>

0 个答案:

没有答案