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

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; }
}<div class="sunray"></div>
发布于 2020-01-05 05:52:34
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);
}
}<div class="container">
<div class="sunray"></div>
</div>
https://stackoverflow.com/questions/59594931
复制相似问题