33
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CSSでテキストを踊らせる。

Posted at

sample.gif


<div class="text">
  <span>C</span>
  <span>S</span>
  <span>S</span>
  <span></span>
</div>

.text{
  font-size: 3em;
  color: white;
}

.text span{ 
  display: inline-block;
  animation: textAnim 1s linear infinite alternate;
}

@keyframes textAnim{
  from{
    transform-origin: left bottom;
    transform: rotate(-15deg);
  }
  to{
    transform-origin: right bottom;
    transform: rotate(+15deg);
  }
}

ポイントは アニメーションで transform-originを変化させること。
これによって、踊っているように見える。

spandisplay: inline-blockと指定している。
これは デフォルトのinlineだと transformが効かないため。

33
33
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
33
33

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?