如何让立方体绕斜对角线做3D旋转,并且使轴垂直于水平面

现在有个需求,想要立方体绕斜对角线做3D旋转,并且使轴垂直于水平面
下面代码是我网上找的微调以后的结果(原地址),调了一天还是达不到效果,恳请大佬指点迷津!
如图

<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <title>立方体</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
      .wrap {
        position: relative;
        transform-style: preserve-3d;
        /* transform: rotateX(-45deg) rotateY(45deg); */
        /* transform: rotate3d(1, 1, 1, 360deg); */
        /* animation: willRote2 20s linear infinite; */
      }
        ul{
            width: 200px;
            height: 200px;
            /* background: #fff; */
            margin: 100px auto;
            position: relative;
            transform-style: preserve-3d;
            /* transform: rotateX(-45deg) rotateY(45deg); */
            animation: willRote 10s linear infinite;
        }
        @keyframes willRote {
            0% {
                transform: rotateX(-45deg) rotateY(45deg) rotateZ(0);
            }
            100% {
                transform: rotateX(-45deg) rotateY(45deg) rotateZ(360deg);
            }
        }
        @keyframes willRote2 {
            0% {
                transform: rotate3d(0, 0, 0, 0);
            }
            100% {
                transform: rotate3d(-1, 1, -1, 360deg);
            }
        }
        ul li{
            list-style: none;
            width: 200px;
            height: 200px;
            text-align: center;
            line-height: 200px;
            font-size: 40px;
            position: absolute;
        }
        ul li:nth-child(1){
            background-color: rgba(0,0,255,0.7);
            transform: rotateX(90deg) translateZ(100PX);
        }
        ul li:nth-child(2){
            background-color: rgba(255,69,0,0.7);
            transform: rotateY(180deg) translateZ(100PX);
        }
        ul li:nth-child(3){
            background-color:rgba(11,23,70,0,7);
            transform: rotateX(-90deg) translateZ(100PX);
        }
        ul li:nth-child(4){
            background-color:rgba(255,255,0,0.7);
            transform: rotateX(360deg) translateZ(100PX);
        }
        ul li:nth-child(5){
            background-color: rgba(255,192,203,0.7);
            transform: rotateY(90deg) translateZ(100PX);
        }
        ul li:nth-child(6){
            background-color:rgba(218,112,214,0.7);
            transform: rotateY(-90deg) translateZ(100PX);
        }
    </style>
</head>
<body>
  <div class="wrap">
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
      <li>6</li>
    </ul>
  </div>
</body>
</html>
阅读 2.5k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏