使一条线从(0,0)移动到任何角度

时间:2017-04-20 05:59:52

标签: css3 css-animations

我创建了一条线,在鼠标悬停时从0到全长显示。在此代码中,线条从左向右移动。我只想让它从(0,0)移动到任何给定的角度。有什么方法可以实现这个目标吗?

.cspaceintro .intro-container .line2 {
  position: relative;
  left: 890px;
  bottom: 25px;
  width: 2%;
  height: 30px;
  background-color: #3ebbff;
  background: -webkit-gradient(linear, 0 0, 0 100%,from(#7BC3FF), to(#7BC3FF));
  -webkit-animation: aaa 2s linear 1;
  -webkit-animation-fill-mode: both;
}

@keyframes aaa {
  0% {
    width: 0%;
  }
  30% {
    width: 2%;
  }
  60% {
    width: 4%;
  }
  100% {
    width: 5%;
  }
}
<div class="cspaceintro">
  <div class="intro-container">
    <div id="li2"></div>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

您可以使用CSS3属性transform和transform-origin。

.cspaceintro {
  /* rotate to the respective degrees */
  -webkit-transform: rotate(45deg);
  transform: rotate(45deg);

  /* sets the origin point for the transformed element */
  -webkit-transform-origin: 0;
  transform-origin: 0;
}

请参阅链接:https://developer.mozilla.org/en/docs/Web/CSS/transform?v=example#Live_example