[英]Triggering multiple CSS animations with hovering over one element
I am having issues triggering multiple css hover animations. 我在触发多个CSS悬停动画时遇到问题。 Currently there are 3 different divs that all need different animations when the main parent div is hovered over with a mouse.
当前,当主父div用鼠标悬停时,有3种不同的div都需要不同的动画。
<div class="col-lg-7 dasHb">
<div id="dashBoard"></div>
<div id="dashCircle"></div>
<div id="dashTri"></div>
</div>
div#dashBoard{
background: url(../img/homepage_dashboard_image.svg) no-repeat;
background-size: contain;
height: 93.4rem;
width: 100%;
position: absolute;
left: -2rem;
top: -4rem;
}
div#dashBoard:hover{
transform: rotateY(-22deg) rotateX(-7deg) rotateZ(3deg);
transition: all 600ms;
}
div#dashCircle{
background: url(../img/graphic_circle_purple.svg) no-repeat;
background-size: contain;
height: 7.4rem;
width: 17%;
position: absolute;
left: -2rem;
top: 4rem;
z-index: -3;
}
div#dashCircle:hover{
top: -8rem;
transition: all 600ms;
}
div#dashTri{
background: url(../img/graphic_triangle.svg) no-repeat;
background-size: contain;
height: 6.4rem;
width: 17%;
position: absolute;
z-index: -3;
top: 17rem;
left: 30rem;
transform: rotateZ(39deg);
}
div#dashTri:hover{
transform: rotateZ(-71deg);
transition: all 600ms;
top: 18rem;
left: 29rem;}
I would like the 3 divs (dashBoard, dashCircle, dashTri) to all go through their respective animations/transforms when the main dasHb div is hovered over. 当主dasHb div悬停在上面时,我希望3个div(dashBoard,dashCircle,dashTri)全部通过各自的动画/变换。 Can anybody please help?
有人可以帮忙吗?
Thanks. 谢谢。
Intead use div#dashCircle:hover
use .dasHb:hover #dashCircle{}
... 集成使用
div#dashCircle:hover
使用.dasHb:hover #dashCircle{}
...
div#dashBoard{ background: url(https://i.stack.imgur.com/3mG2d.jpg) no-repeat; background-size: contain; height: 93.4rem; width: 100%; position: absolute; left: -2rem; top: -4rem; } .dasHb:hover #dashBoard{ transform: rotateY(-22deg) rotateX(-7deg) rotateZ(3deg); transition: all 600ms; } div#dashCircle{ background: url(https://i.stack.imgur.com/3mG2d.jpg) no-repeat; background-size: contain; height: 7.4rem; width: 17%; position: absolute; left: -2rem; top: 4rem; z-index: -3; } .dasHb:hover #dashCircle{ top: -8rem; transition: all 600ms; } div#dashTri{ background: url(https://i.stack.imgur.com/3mG2d.jpg) no-repeat; background-size: contain; height: 6.4rem; width: 17%; position: absolute; z-index: -3; top: 17rem; left: 30rem; transform: rotateZ(39deg); } .dasHb:hover #dashTri{ transform: rotateZ(-71deg); transition: all 600ms; top: 18rem; left: 29rem;}
<div class="col-lg-7 dasHb"> <div id="dashBoard">dashBoard</div> <div id="dashCircle">dashCircle</div> <div id="dashTri">dashTri</div> </div>
More your :hover
pseudo-class up to the parent .dasHb
and then select each child and apply the desired transform. 更多
:hover
伪类,直到父.dasHb
,然后选择每个子对象并应用所需的转换。
.svg { width: 200px; height: 60px; } .red { background: red; } .green { background: green; } .blue { background: blue; } .dasHb:hover .red { transform: rotateZ(-71deg) translate(29rem, 18rem); transition: transform 600ms; } .dasHb:hover .green { transform: translatey(-8rem); transition: all 600ms; } .dasHb:hover .blue { transform: rotateY(-22deg) rotateX(-7deg) rotateZ(3deg); transition: transform 600ms; }
<div class="dasHb"> <div class="svg red"></div> <div class="svg green"></div> <div class="svg blue"></div> </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.