Keep box-shadow direction consistent while rotating

后端 未结 3 1084
长发绾君心
长发绾君心 2020-12-03 10:43

When giving e.g. a

a box-shadow as well as rotating it will cause a rotation of the box-shadow direction - which is problematic when the box-shadow
3条回答
  •  长情又很酷
    2020-12-03 11:30

    You could as well integrate box-shadow direction inside animation frames:

    div {
      display: inline-block;
      margin: 1em ;
      height: 50px;
      width: 50px;
      box-shadow: 15px 15px 15px 5px gray;
      animation: rte 5s infinite linear;
    }
    
    .red {
      background: red
    }
    
    .green {
      background: green;
      animation-delay:2s;
    }
    
    .blue {
      background: blue;
      animation-delay:4s;
    }
    
    .bob {
      background: #b0b;
      animation-delay:6s;
    }
    
    .cyan {
      background: cyan;
      animation-delay:8s;
    }
    
    @keyframes rte {
      25% {
        box-shadow:  15px -15px 15px 5px gray;
      }
      50% {
          box-shadow:  -15px -15px 15px 5px gray;
      }
      75% {
        box-shadow:  -15px 15px 15px 5px gray;
      }
      100% {
        transform: rotate(360deg);
      }
    }

提交回复
热议问题