简体   繁体   English

悬停效果的CSS动画

[英]CSS animation for hover effect

I have a jsfiddle set up of the code I have so far. 到目前为止,我已经设置了jsfiddle代码。 Basically I can't seem to make the rollover animation happen with hover for the main body of text in each ul. 基本上,我似乎无法使悬停动画发生在每个ul文本的主体中。

So when you rollover the individual areas the code for opacity on these classes..... 因此,当您将鼠标悬停在各个区域上时,这些类上的不透明代码.....

.browser .statistic,
.browser .download {
  display: block;
  opacity: 0;
  -webkit-transition: opacity 0.3s ease-in-out;
  -moz-transition: opacity 0.3s ease-in-out;
  -o-transition: opacity 0.3s ease-in-out;
  transition: opacity 0.3s ease-in-out;

Becomes 1. But i can't seem to get the transition animation to happen Can someone point me in the right direction. 变成1。但是我似乎无法使过渡动画发生,有人可以向我指出正确的方向。

Cheers, Greg. 干杯,格雷格。

you need to set the transition on the main class of the object you are trying to animate, not on the class you are adding on hover 您需要在要设置动画的对象的主类上而不是在悬停时添加的类上设置过渡

.initial-element{
  opacity:1;
  -webkit-transition: opacity 0.3s ease-in-out;
  -moz-transition: opacity 0.3s ease-in-out;
  -o-transition: opacity 0.3s ease-in-out;
  transition: opacity 0.3s ease-in-out;
}
.initial-element:hover{
  opacity:0;
}

sorry if i missunderstanding you. 对不起,如果我误会了你。

i just added: 我刚刚补充说:

li:hover .browser * {
    opacity: 1;
    -webkit-transition:opacity 1500ms ease-out;
    -moz-transition:opacity 1500ms ease-out;
    -o-transition:opacity 1500ms ease-out;
    transition:opacity 1500ms ease-out;
}

DEMO: http://jsfiddle.net/zn09vjbv/1/ 演示: http : //jsfiddle.net/zn09vjbv/1/

UPDATE: 更新:

is there any way to get the "h2 span" class to also change its background position when the li is hover ? 有什么办法可以使“ h2 span”类在li悬停时也更改其背景位置?

yes, just add this: (add any attribute you like inside this class) 是的,只需添加以下内容即可:(在此类中添加您喜欢的任何属性)

li:hover .browser h2 {
    background: #000;
    color; #FFF;
    ......
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM