首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何动画展开/收缩而不是向上/向下

如何动画展开/收缩而不是向上/向下
EN

Stack Overflow用户
提问于 2020-01-05 05:17:07
回答 1查看 78关注 0票数 0

我试图让这条线表现得像一束阳光,沿对角线向下移动(↘)和向左向上移动(↖)。我得到的是up/down,尽管使用了高度降低。

在GIF中预览(使用图像编辑器创建):

代码语言:javascript
复制
body {
    background-color: grey;
}

.sunray {
    height: 200px; 
    width: 5px;
    background-color: white;
    opacity: 0.9; 
    filter: blur(5px);  
    transform: rotate(135deg); 
    position: relative;
    left: 60px;
    top: -50px;
} 
   
.sunray {
    animation: ray 1s linear infinite;
    animation-direction: alternate-reverse;
}
   
@keyframes ray {
    from { height: 200px; }
    to   { height: 50px; }
}
代码语言:javascript
复制
<div class="sunray"></div>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-05 05:52:34

代码语言:javascript
复制
body {
  background-color: grey;
}

.container {
  height: 200px;
  width: 200px;
  overflow: hidden;
  outline: 1px solid black;
}

.sunray {
  height: 200px;
  width: 5px;
  background-color: white;
  opacity: 0.9;
  filter: blur(5px);
  position: relative;
  left: 60px;
  top: -50px;
}

.sunray {
  animation: ray 1s linear infinite;
  animation-direction: alternate-reverse;
}

@keyframes ray {
  from {
    transform: translate(-50px, -50px) rotate(-45deg);
  }
  to {
    transform: rotate(-45deg);
  }
}
代码语言:javascript
复制
<div class="container">
  <div class="sunray"></div>
</div>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59594931

复制
相关文章

相似问题

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