纯css实现webpack的logo转动

原效果

纯css实现webpack的logo转动_第1张图片

实现效果

纯css实现webpack的logo转动_第2张图片

源码

DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Documenttitle>
head>

<body>
  <style>
    :root {
      --time: 16s;
    }

    * {
      height: 100%;
      width: 100%;
      border: 0;
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .logo {
      position: relative;
      background-color: #2b3a42;
    }

    .cube__container {
      position: absolute;
      margin: auto;
      inset: 0;
      /* top等4个方向的简写 */
      height: 180px;
      width: 180px;
    }

    .cube__container:hover .cube__outer,
    .cube__container:hover .cube__inner,
    .cube__container:hover .cube__outer__face__1,
    .cube__container:hover .cube__outer__face__3,
    .cube__container:hover .cube__outer__face__4,
    .cube__container:hover .cube__outer__face__5,
    .cube__container:hover .cube__outer__face__6 {
      animation-play-state: paused;
    }

    .cube {
      transform-style: preserve-3d;
      transform: rotateX(-33.5deg) rotateY(45deg);
      position: relative;
    }

    .cube__inner,
    .cube__outer {
      transform-style: preserve-3d;
      display: inline-block;
      width: 120px;
      height: 120px;
    }

    .cube__outer {
      transform: translateX(-50%) scale3d(1, 1, 1) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
      animation: cube__outer__rotate var(--time) infinite;
    }

    .cube__inner {
      position: absolute;
      inset: 0;
      transform: translateX(-50%) scale3d(0.5, 0.5, 0.5) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
      animation: cube__inner__rotate var(--time) infinite;
    }

    .cube__face {
      border: 1px solid #fff;
      position: absolute;
    }

    .cube .cube__outer .cube__face {
      background: #8dd6f980;
    }

    .cube .cube__inner .cube__face {
      background: #175d96;
      border: 2px solid #fff;
    }

    .cube__face__1 {
      transform: rotateX(0deg) translateZ(60px);
    }

    .cube__outer__face__1 {
      animation: face1 var(--time) infinite linear;
    }

    .cube__face__2 {
      transform: rotateX(-90deg) translateZ(60px);
    }

    .cube__face__3 {
      transform: rotateX(90deg) translateZ(60px);
    }

    .cube__outer__face__3 {
      animation: face3 var(--time) infinite linear;
    }

    .cube__face__4 {
      transform: rotateY(-90deg) translateZ(60px);
    }

    .cube__outer__face__4 {
      animation: face4 var(--time) infinite linear;
    }

    .cube__face__5 {
      transform: rotateY(90deg) translateZ(60px);
    }

    .cube__outer__face__5 {
      animation: face5 var(--time) infinite linear;
    }

    .cube__face__6 {
      transform: rotateY(180deg) translateZ(60px);
    }

    .cube__outer__face__6 {
      animation: face6 var(--time) infinite linear;
    }
  style>

  <style>
    @keyframes cube__outer__rotate {
      0% {
        transform: rotateY(0deg);
      }

      25% {
        transform: rotateY(90deg);
      }

      50% {
        transform: rotateY(180deg);
      }

      75% {
        transform: rotateY(270deg);
      }

      100% {
        transform: rotateY(360deg);
      }
    }

    @keyframes cube__inner__rotate {
      0% {
        transform: rotateY(0deg) scale3d(0.5, 0.5, 0.5);
      }

      25% {
        transform: rotateY(-90deg) scale3d(0.5, 0.5, 0.5);
      }

      50% {
        transform: rotateY(-180deg) scale3d(0.5, 0.5, 0.5);
      }

      75% {
        transform: rotateY(-270deg) scale3d(0.5, 0.5, 0.5);
      }

      100% {
        transform: rotateY(-360deg) scale3d(0.5, 0.5, 0.5);
      }
    }

    @keyframes face1 {
      0% {
        border-width: 1px 6px 6px 1px;
      }

      25% {
        border-width: 1px;
      }

      50% {
        border-width: 1px;
      }

      75% {
        border-width: 1px 1px 6px 6px;
      }

      100% {
        border-width: 1px 6px 6px 1px;
      }
    }

    @keyframes face3 {
      0% {
        border-width: 6px 6px 1px 1px;
      }

      25% {
        border-width: 1px 6px 6px 1px;
      }

      50% {
        border-width: 1px 1px 6px 6px;
      }

      75% {
        border-width: 6px 1px 1px 6px;
      }

      100% {
        border-width: 6px 6px 1px 1px;
      }
    }

    @keyframes face4 {
      0% {
        border-width: 1px 1px 6px 6px;
      }

      25% {
        border-width: 1px 6px 6px 1px;
      }

      50% {
        border-width: 1px;
      }

      75% {
        border-width: 1px;
      }

      100% {
        border-width: 1px 1px 6px 6px;
      }
    }

    @keyframes face5 {
      0% {
        border-width: 1px;
      }

      25% {
        border-width: 1px;
      }

      50% {
        border-width: 1px 1px 6px 6px;
      }

      75% {
        border-width: 1px 6px 6px 1px;
      }

      100% {
        border-width: 1px;
      }
    }

    @keyframes face6 {
      0% {
        border-width: 1px;
      }

      25% {
        border-width: 1px 1px 6px 6px;
      }

      50% {
        border-width: 1px 6px 6px 1px;
      }

      75% {
        border-width: 1px;
      }

      100% {
        border-width: 1px;
      }
    }
  style>
  <div class="logo">
    <div class="cube__container">
      <div class="cube">
        <figure class="cube__outer">
          <section class="cube__face cube__face__1 cube__outer__face__1">section>
          <section class="cube__face cube__face__2">section>
          <section class="cube__face cube__face__3 cube__outer__face__3">section>
          <section class="cube__face cube__face__4 cube__outer__face__4">section>
          <section class="cube__face cube__face__5 cube__outer__face__5">section>
          <section class="cube__face cube__face__6 cube__outer__face__6">section>
        figure>
        <figure class="cube__inner">
          <section class="cube__face cube__face__1">section>
          <section class="cube__face cube__face__2">section>
          <section class="cube__face cube__face__3">section>
          <section class="cube__face cube__face__4">section>
          <section class="cube__face cube__face__5">section>
          <section class="cube__face cube__face__6">section>
        figure>
      div>
    div>
  div>

body>

html>

你可能感兴趣的:(css,webpack,前端,动画)