[英]CSS Selectors - Multiple animations on one trigger
How can I get multiple divs to transition/animate on one hover trigger? 如何在一个悬停触发器上获得多个div过渡/动画?
See the update here: http://jsfiddle.net/hecyn/9/ >> CSS-Line:23 All I'm trying to here, is to get .inner and .wrap2 to rotate on one .wrap:hover. 请参阅此处的更新: http : //jsfiddle.net/hecyn/9/ >> CSS-Line:23我要在这里做的就是让.inner和.wrap2在一个.wrap:hover上旋转。 Its not working, when I add the "+" selector. 当我添加“ +”选择器时,它不起作用。 How can I right this better. 我怎样才能更好地解决这个问题。
Primary Question: So simply how can I write this below: 主要问题:那么我该如何在下面写这个:
#container:hover + #cube1 + #cube2 + #cube3 { background-color: yellow; }
Second question: Above would be ok, but ultimately Im kinda trying to achieve this via CSS: 第二个问题:上面没关系,但是最终我还是想通过CSS来实现这一点:
#:hoverOverSomething then{
Do this thing;
Do this other thing;
Do this next thing;
}
Bear with me, little new to CSS animations... and the net is clouded and without specific simple information. 忍受我,CSS动画的新手少了……整个网络浑浊,没有特定的简单信息。 Cheers. 干杯。
I think you could try keyframes animation: https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes 我认为您可以尝试使用关键帧动画: https : //developer.mozilla.org/en-US/docs/Web/CSS/@keyframes
Something like this: 像这样:
.wrap:hover {
animation: test-animation 2s linear;
}
@keyframes test-animation {
//You can add as many ranges as you like from 0% to 100%
0% { opacity: 0; }
50% { transform: scale(1.5); }
100% { opacity: 1; }
}
https://jsfiddle.net/maLt4dda/ https://jsfiddle.net/maLt4dda/
Regarding the question: 关于这个问题:
How can I get multiple divs to transition/animate on one hover trigger? 如何在一个悬停触发器上获得多个div过渡/动画?
Your idea is fine, but there is one mistake in the code. 您的想法很好,但是代码中有一个错误。 It should be .wrap:hover .inner,.wrap:hover + .wrap2
instead of .wrap:hover .inner + .wrap2
它应该是.wrap:hover .inner,.wrap:hover + .wrap2
而不是.wrap:hover .inner + .wrap2
something like this ? 这样的事情?
div{width:100px;height:50px;background-color:red;border:1px solid black;margin:2px;} #container:hover ~.hover { background-color: yellow; }
<div id="container"class="hover">Container</div> <div id="cube1" class="hover">Cube 1</div> <div id="cube2" class="hover">Cube 2</div> <div id="cube3" class="hover">Cube 3</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.