首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用CSS3动画和Sass @for循环触发列表

使用CSS3动画和Sass @for循环触发列表
EN

Stack Overflow用户
提问于 2016-11-28 21:13:10
回答 1查看 337关注 0票数 2

我试图用一个for循环在Sass中创建一个关键帧动画,但我在编写它时遇到了困难。我想要的是让每个单独的项目一个接一个地出现,但有一个小小的延迟。有点像一堆纸牌。

这是一个codepen。代码如下:

代码语言:javascript
复制
<ul>
  <li><a href="#About">About</a></li>
  <li><a href="#Contact">Contact</a></li>
  <li><a href="Labs">Labs</a></li>
</ul>
代码语言:javascript
复制
html {
  font-size: 62.5%;
   box-zising: border-box;
}

*,
*:before,
*:after {
  box-zising: inherit;
}

html, body {
  width: 100vw;
  height: 100vh;
  background: black;
  font-size: 1rem;
}


ul {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid white;
  width: 100vw;
  height: 100vh;
}

li {
  list-style: none;
  border: 1px solid white;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  background: red;

  @for $i from 1 through 4 {
    &:nth-of-type(#{$i}) {
      animation: slideTop;
      animation-duration: 1.5s + (40ms * $i);
      animation-iteration-count: 5;
      animation-delay: 2.5s + (40ms * $i);
    }
  }

  a {
    display: block;
    padding: 50px;
    color: white;
    font-size: 24px;
    text-decoration: none;
    letter-spacing: 0.1em;
  }
}


@keyframes slideTop {
  0% {
    opacity: 0;
    transform: scaleY(0);
  }
  100% {
    opacity: 1;
    transform: scaleY(50px);
  }
}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40845209

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档