gpt4 book ai didi

css - 难以叠加纯 CSS 动画

转载 作者:行者123 更新时间:2023-11-28 09:42:52 25 4
gpt4 key购买 nike

我从其他地方借用了一个维恩动画,并想在维恩中放置图标(通过 CSS 类的 ionic 图标),以便它们根据它进行动画处理。

我尝试了很多方法,但到目前为止,我最接近成功的方法是基本上运行两组动画,使用相同的参数,在代码中一个接一个地运行。

虽然现在符号和 CSS 圆圈的动画相同,但它们不占用相同的空间,因此不会按我的意愿叠加。在现有代码设置中,我如何实现这一目标?我试过填充、边距等,但会扭曲圆形图形。

谢谢。

动画不会在 Stack Overflow 编辑器中运行,因此请在 Codepen 上查看: Link to animation on Codepen.

* {
box-sizing: border-box;
}
body {
background-image: radial-gradient(#fff 25%, #bbb 75%);
height: 100vh;
width: 100vw;
position: relative;
display: flex;
align-items: center;
justify-content: center;
}


.box {
height: 50vh;
width: 50vh;
}
[class^='c'] {
background-color: #0ff;
border-radius: 50%;
height: 50vh;
width: 50vh;
mix-blend-mode: multiply;
position: absolute;
}
.circle1 { /*blue*/
background-color: rgba(0,255,255,0.5);
animation: c1 2.5s ease 4 forwards;
}

/*.ion-code{
animation: code-symbol 2.5s ease 4 forwards;
transform: translate(15%, -12%);
}*/

.circle2 { /*yellow*/
background-color: rgba(255,255,0,0.5);
animation: c2 2.5s ease 4 forwards ;
}
.circle3 {/*pink*/
background-color: rgba(255,0,255,0.5);
animation: c3 2.5s ease 4 forwards ;
}
/*---------------------------------------C1-BLUE-*/

@keyframes c1 {
0% {transform: translate(0, 0); }
100% {transform: translate(-25%, 25%); }
}

/*@keyframes code-symbol {
0% {transform: translate(0, 0); }
100% {transform: translate(-25%, 25%); }
}*/

/*---------------------------------------C2-YELLOW-*/

@keyframes c2 {
from {
transform: translate(0, 0);

}
to {


transform: translate(0, -25%);
}
}

/*---------------------------------------C3-PINK-*/

@keyframes c3 {
from {
transform: translate(0, 0);

}
to {

transform: translate(25%, 25%);
}
}

/*--------Symbol layer -----------*/

[class^='ion-'] {
border-radius: 50%;
height: 150vh;
width: 150vh;
mix-blend-mode: multiply;
position: absolute;
}

.ion-code { /*blue*/
/*background-color: rgba(0,255,255,0.5);*/
animation: ion-code 2.5s ease 4 forwards;
font-size: 4rem;

}

.ion-arrow-graph-up-right { /*yellow*/
/* background-color: rgba(255,255,0,0.5); */
animation: ion-arrow-graph-up-right 2.5s ease 4 forwards;
font-size: 4rem;
}
.ion-ios-settings-strong {/*pink*/
/* background-color: rgba(255,0,255,0.5); */
animation: ion-ios-settings-strong 2.5s ease 4 forwards;
font-size: 4rem;
}
/*---------------------------------------C1-BLUE-*/

@keyframes ion-code {
from {transform: translate(0, 0); }
to {transform: translate(-25%, 25%); }
}

/*---------------------------------------C2-YELLOW-*/

@keyframes ion-arrow-graph-up-right {
from {transform: translate(0, 0);}
to {transform: translate(0, -25%);}
}

/*---------------------------------------C3-PINK-*/

@keyframes ion-ios-settings-strong {
from {transform: translate(0, 0);}
to {transform: translate(25%, 25%);}
}
<body>  
<div class="box">
<div class="circle1 ion-code" ></div>
<div class="circle2 ion-arrow-graph-up-right"></div>
<div class="circle3 ion-ios-settings-strong"></div>
</div>
</body>

最佳答案

在此示例中,您只需要定位图标所在的 :before 伪元素

SEE CODEPEN

.circle1:before, .circle2:before, .circle3:before {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
}

干杯。

关于css - 难以叠加纯 CSS 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52742138/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com