如果你看一下下面的例子,当鼠标悬停在它上面时,CSS转换会变得生动。如何在不用鼠标悬停在其上的情况下实现此效果?我希望能够在某些情况下使用jQuery添加类,当它这样做时,应该触发CSS转换。我需要改变什么?感谢
.hvr-bounce-to-right {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
-webkit-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
}
.hvr-bounce-to-right:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #2098d1;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transform-origin: 0 50%;
transform-origin: 0 50%;
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-duration: 0.5s;
transition-duration: 0.5s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.hvr-bounce-to-right:hover, .hvr-bounce-to-right:focus, .hvr-bounce-to-right:active {
color: white;
}
.hvr-bounce-to-right:hover:before, .hvr-bounce-to-right:focus:before, .hvr-bounce-to-right:active:before {
-webkit-transform: scaleX(1);
transform: scaleX(1);
-webkit-transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
transition-timing-function: cubic-bezier(0.52, 1.64, 0.37, 0.66);
}
<a href="#" class="hvr-bounce-to-right">Bounce To Right</a>
答案 0 :(得分:0)
您可以使用setTimeout将元素添加到元素中。
例如。
.hvr-bounce-to-right{
//your style
}
.hvr-bounce-to-right.new-class:before{
your hover effect
}
然后使用java脚本只需使用setTimeout添加此(new-class)。它应该工作