Help us understand the problem. What is going on with this article?

CSSで月を表現してみた。

More than 3 years have passed since last update.

full_moon.gif

html
<div class="moon"></div>

css
.moon{
  width: 300px;
  height: 300px;
  border-radius: 100%;
  animation: anime 10s linear;
  /* アニメーション終了時の状態(値)を維持 */
  -webkit-animation-fill-mode: forwards;
}

@keyframes anime{
  from{
    box-shadow: none;
  }

  to{
    /* 満月 */
    box-shadow: 300px -100px 0 0 #FEE489 inset;
    /* 三日月 */
    /*box-shadow: -100px 0 0 0 #FEE489 inset;*/
  }
}

三日月も作ってみた
crescent.gif

animation-fill-mode

animation-fill-mode: forwards;でアニメーション終了時の状態(値)を維持できます
これを指定しないとアニメーション実行前の状態(値)に戻ってしまう。

下記のサイトから引用しています。

animation-fill-mode CSS プロパティは、CSS アニメーションの適用先に対して、アニメーションの実行前や実行後にどのようなスタイルを適用するかを設定します。

animation-fill-mode - CSS | MDN

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away