リスト要素を入れ子にしてCSSのみで作るドロップダウンメニューはよくありますが、このサンプルは、サブメニューを下に展開する際にアニメーション効果が付きます。サンプルは、一段目が「STYLE 1」から「STYLE 4」まで、二段目がSTYLE 5」から「STYLE 」まで計8種類あり、hoverすると、それぞれ5個のサブメニューを8種類の違った動きでひとつずつ展開します。

STYLE 1部分のhtmlソース

<div class="nav">
    <ul>
      <li>STYLE 1 
        <ul class="drop-menu menu-1">
          <li>ONE</li>
          <li>TWO</li>
          <li>THREE</li>
          <li>FOUR</li>
          <li>FIVE</li>
        </ul>
      </li>
      /* 以下略 */

STYLE 1部分のCSSソース

ul.drop-menu li {
  display: none;
}

li:hover > ul.drop-menu li {
  display: block;
}

li:hover > ul.drop-menu.menu-1 {
  perspective: 1000px;
}
li:hover > ul.drop-menu.menu-1 li {
  transform-origin: top left;
  opacity: 0;
}
li:hover > ul.drop-menu.menu-1 li:nth-child(1) {
  animation-name: menu-1;
  animation-duration: 300ms;
  animation-delay: -150ms;
  animation-fill-mode: forwards;
  animation-timing-function: ease-in-out;
}
li:hover > ul.drop-menu.menu-1 li:nth-child(2) {
  animation-name: menu-1;
  animation-duration: 300ms;
  animation-delay: 0ms;
  animation-fill-mode: forwards;
  animation-timing-function: ease-in-out;
}
li:hover > ul.drop-menu.menu-1 li:nth-child(3) {
  animation-name: menu-1;
  animation-duration: 300ms;
  animation-delay: 150ms;
  animation-fill-mode: forwards;
  animation-timing-function: ease-in-out;
}
li:hover > ul.drop-menu.menu-1 li:nth-child(4) {
  animation-name: menu-1;
  animation-duration: 300ms;
  animation-delay: 300ms;
  animation-fill-mode: forwards;
  animation-timing-function: ease-in-out;
}
li:hover > ul.drop-menu.menu-1 li:nth-child(5) {
  animation-name: menu-1;
  animation-duration: 300ms;
  animation-delay: 450ms;
  animation-fill-mode: forwards;
  animation-timing-function: ease-in-out;
}
li:hover > ul.drop-menu.menu-1 li:nth-child(6) {
  animation-name: menu-1;
  animation-duration: 300ms;
  animation-delay: 600ms;
  animation-fill-mode: forwards;
  animation-timing-function: ease-in-out;
}
@keyframes menu-1 {
  0% {
    opacity: 0;
    transform: rotateZ(90deg);
  }
  70% {
    transform: skewX(10deg);
  }
  100% {
    opacity: 1;
    transform: rotateZ(0deg);
  }
}

 

 

引用と参考;https://codepen.io/southface/pen/GqYWJk
戻るボタン