如何使用 css 为弹跳和不透明度变化设置动画

How to animate bounce and opacity change with css

我想用动画重新创建加载状态,并希望在完成时复制弹跳和不透明度变化 here。看起来它是通过 React 完成的,但想知道是否可以使用纯 css 或类似的 js(我不知道 React :/ )

我使用 css

尝试了以下方法
<div class="Loading__StyledLoading-sc-1psg3na-0 hhImes" data-test="loading">
  <div class="Loading__StyledLoader-sc-1psg3na-4 ggWVnQ">
    <div class="Loading__StyledLoaderCircle-sc-1psg3na-5 fFoXSV"></div>
    <div class="Loading__StyledLoaderCircle-sc-1psg3na-5 fFoXSV"></div>
    <div class="Loading__StyledLoaderCircle-sc-1psg3na-5 fFoXSV"></div>
  </div>
  <div type="inlineLoader" class="Loading__StyledLoadingText-sc-1psg3na-1 hqLQhc">Please wait, content of the page is loading...</div>
</div>

css

.fFoXSV:nth-child(2) {
    animation-delay: 0.1s;
}

.fFoXSV:nth-child(3) {
    animation-delay: 0.2s;
    margin-top: 0px;
}

.css-sqdry3{
    position:absolute;
    box-sizing:border-box;
    top:0;
    left:0;
    width:100%;
    height:100%;
    opacity:1;
    z-index:9;
    -webkit-transition:width 0.1s ease-out,height 0.1s ease-out,top 0.1s ease-out,left 0.1s ease-out,background 0.1s ease-out,opacity 0.1s ease-out,-webkit-transform 0.1s ease-out;
    -webkit-transition:width 0.1s ease-out,height 0.1s ease-out,top 0.1s ease-out,left 0.1s ease-out,background 0.1s ease-out,opacity 0.1s ease-out,transform 0.1s ease-out;
    transition:width 0.1s ease-out,height 0.1s ease-out,top 0.1s ease-out,left 0.1s ease-out,background 0.1s ease-out,opacity 0.1s ease-out,transform 0.1s ease-out;
  }

感谢任何帮助。 TIA!

是的,只有 css 才有可能。您可以使用 animation-csskeyframes 属性.

来完成此操作

试试下面的代码和 css.

.fFoXSV:nth-child(2) {
    animation-delay: 0.1s;
}

.fFoXSV:nth-child(3) {
    animation-delay: 0.2s;
    margin-top: 0px;
}

.css-sqdry3{
    position:absolute;
    box-sizing:border-box;
    top:0;
    left:0;
    width:100%;
    height:100%;
    opacity:1;
    z-index:9;
    -webkit-transition:width 0.1s ease-out,height 0.1s ease-out,top 0.1s ease-out,left 0.1s ease-out,background 0.1s ease-out,opacity 0.1s ease-out,-webkit-transform 0.1s ease-out;
    -webkit-transition:width 0.1s ease-out,height 0.1s ease-out,top 0.1s ease-out,left 0.1s ease-out,background 0.1s ease-out,opacity 0.1s ease-out,transform 0.1s ease-out;
    transition:width 0.1s ease-out,height 0.1s ease-out,top 0.1s ease-out,left 0.1s ease-out,background 0.1s ease-out,opacity 0.1s ease-out,transform 0.1s ease-out;
  }

.hhImes {
    min-height: 19px;
    display: inline-flex;
    flex-direction: row;
    -webkit-box-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    align-items: center;
    overflow: hidden;
    box-sizing: border-box;
}
.ggWVnQ {
    display: flex;
    -webkit-box-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    align-items: center;
}

.fFoXSV {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    background: rgb(186, 199, 213);
    animation: 1.25s ease-in-out 0s infinite normal none running eugkhY;
}

@keyframes eugkhY{
    0% {
        opacity: 0.3;
        transform: translateY(0px);
    }
    20% {
        opacity: 1;
        transform: translateY(-3px);
    }
    40% {
        opacity: 0.3;
        transform: translateY(0px);
    }
    100% {
        opacity: 0.3;
        transform: translateY(0px);
    }
}
<div class="hhImes" data-test="loading">
  <div class="ggWVnQ">
    <div class="fFoXSV"></div>
    <div class="fFoXSV"></div>
    <div class="fFoXSV"></div>
  </div>
  <div type="inlineLoader" class="hqLQhc">Please wait, content of the page is loading...</div>
</div>