study-note

6. アニメーションのCSS

目次


トランジション

transitionプロパティ

#child{
  transition:
    color 1s linear 0s,
    background-color 1s linear 0s;
}
#child:hover{
  color: red;
  background-color: black;
  translate: 50px;
  rotate: 30deg;
  scale: 2;
}


アニメーション

animationプロパティ

#child{
  animation: anime1 3s linear 0s infinite normal both;
}
@keyframes anime1{
  0%{rotate: 0deg;}
  100%{rotate: 360deg;}
}


三次元

親要素に三次元のCSSを指定する

  1. transform-styleプロパティ:子要素の次元を決める - preserve-3d:三次元に配置する値 - flat:二次元に配置する値

  2. perspectiveプロパティ:子要素とユーザとの間の距離を決める(遠近感)


  1. 子要素を三次元回転させる
  #child{
    rotate: y 40deg;
  }
  1. 子要素を三次元移動させる
  #child{
    translate: 100px 0px 0px;
  }
  1. 子要素を三次元伸縮させる
  #child{
    scale: 1.5 1 1;
  }


7. ユニークなCSS