ログイン
問題9

縦に回るボックスアニメーションを実装しよう

アイコン画像

問題9:縦に回るボックスアニメーションを実装しよう

縦回転アニメーションするblock要素を実装しよう

見本を動画を参考に作成してください。

ブラウザのアイコン期待する画面


タグアイコン解答ソースコード

              <section class="box-cat">
  <label class="box-cat__tab" for="green">緑色</label>
  <label class="box-cat__tab" for="blue">青色</label>
  <label class="box-cat__tab" for="red">赤色</label>
  <input type="radio" name="tabs" id="green">
  <input type="radio" name="tabs" id="blue">
  <input type="radio" name="tabs" id="red"> 

  <div class="box-cat__cube">
    <div class="box-cat__tab-content">
      <p>緑色</p>
    </div>
    <div class="box-cat__tab-content">
      <p>青色</p>
    </div>
    <div class="box-cat__tab-content">
      <p>赤色</p>
    </div>
  </div>
</section>
¥HTML¥
            
              .box-cat {
    width: 300px;
    color: #fff;
    text-align: center;
}
input {
    display: none;
}
.box-cat__tab {
    display: inline-block;
    width: 90px;
    margin-bottom: 55px;
}
.box-cat__tab:nth-child(1) { 
    top: -5px;
    background: green;
}
.box-cat__tab:nth-child(2) {
    top: 69px;
    background: blue;
}
.box-cat__tab:nth-child(3) {
    top: 143px;
    background: red;
}
.box-cat__cube {
    transform-origin: 0 100px;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-in;
}
.box-cat__tab-content {
    width: 300px;
    height: 200px;
    position: absolute;
}
p {
    font-size: 25px;
    margin: 75px 0 10px;
    font-weight: 300;
}
.box-cat__tab-content:nth-child(1) {
    transform: rotateX(-270deg)
                translateY(-100px);
    transform-origin: top left;
    background: green;
}
.box-cat__tab-content:nth-child(2) {
    transform: translateZ(100px);
    background: blue;
}
.box-cat__tab-content:nth-child(3) {
    transform: rotateX(-90deg)
                translateY(100px);
    transform-origin: bottom center;
    background: red;
} 
#green:checked ~ .box-cat__cube {
    transform: rotateX(-90deg);
}
#blue:checked ~ .box-cat__cube {
    transform: rotateX(0deg);
}
#red:checked ~ .box-cat__cube {
    transform: rotateX(90deg);
}
¥CSS¥
            

コメントのアイコン解説

クリック動作はinputタグにて行いましょう。

transform: rotateXを上手く使いアニメーションを付与します。

また、後ろ面を上手く返す為に
transform-origin: bottom center;を付与することで綺麗に前面になります。
ログインして解答を見る
完了にする!
twitterのアイコン
活動記録をTweetする
1.HTMLの宣言をしてみよう
続きの動画を見たい方は公式LINEから「HTML」と送信すると動画が見れます。
HTML_CSSを学ぶなら現役エンジニア監修「甲賀コース」
LINEの友達追加でお役立ち動画をGET!!

閉じる