css设计立方体旋转效果遇到的问题及理解解决方法

        今日在学习立方体旋转效果这里的时候,了解了老师的思路后自己先尝试做了一个,最终旋转使旋转了,但看起来总感觉怪怪的,旋转轴跟想要的效果不一样        

        .one li a:first-child{
            background-color: skyblue;
        }
        .one li a:last-child{
            background-color: orange;
            transform: rotateX(90deg) translateZ(20px) translateY(-20px);
        }

最初只是移动了立方体顶部的盒子来造出立方体,后来查资料才知道立方体的空间坐标系原点一直是不变的,这样我的立方体正面一直在面xoy上,所以如果想实现一个立方体原地旋转的效果,每个面都需要移动

对原来的代码进行改进

        .one li a:first-child{
            background-color: skyblue;
            transform: translateZ(20px);
        }
        .one li a:last-child{
            background-color: orange;
            transform: rotateX(90deg) translateZ(20px);
        }

立方体旋转错误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>Document</title>
    <style>
        *{
            list-style: none;
            margin: 0;
            padding: 0;
            text-decoration: none;
            
        }
        .one{
            width: 270px;
            height: 40px;
            margin: 100px auto;
            transform: rotateY(20px) rotateX(20px);
            /* position: relative; */
        }

         .one li{
            display: block;
            width: 90px;
            height: 40px;
            transform-style: preserve-3d;
            float: left;
            transition: all 0.5s;
        }
        .one li a:first-child{
            background-color: skyblue;
            transform: translateZ(20px);
        }
        .one li a:last-child{
            background-color: orange;
            transform: rotateX(90deg) translateZ(20px);
        }
        a{
            color: black;
            display: block;
            width: 100%;
            height: 100%;
            
            
            line-height: 40px;
            text-align: center;
            position: absolute;
            left: 0;
            top: 0;
        }
       .one li{
        position: relative;
       }
       
       .one li:hover {
        transform: rotateX(-90deg) ;
        
       }
       
       
    </style>
</head>
<body>
    
        <div class="one">
        <ul>
            <li>
                <a href="#">登录</a>
                <a href="#">inter</a>
            </li>
            <li>
                <a href="#">注册</a>
                <a href="#">zhuce</a>
            </li>
            <li>
                <a href="#">历史</a>
                <a href="#">lishi</a>
            </li>
        </ul>
        </div>
    
</body>
</html>

(哪位大佬能提供一些好用的画图工具给我吗,电脑自带的太难用了(ToT)/~~~)

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值