html5+css实现3D导航栏

代码如下:

<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <title>测试</title>
    <meta charset="utf-8">
    <style>
        * {
            margin: auto;
        }
        
        ul {
            list-style-type: none;
            padding: 0%;
            width: 320px;
            height: 50px;
            margin-top: 400px;
        }
        
        li {
            float: left;
            width: 80px;
            height: 50px;
            text-align: center;
            position: relative;
            transform-style: preserve-3d; /*将li标签从平面转换为3D*/
            /* perspective: 1000px; */  /*透视距离(这个地方不用)*/
            line-height: 50px;
            transition: all 0.5s; /*过渡时间*/
        }
        
        li>a {
            display: block;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            position: absolute;  
            color: white;
            text-decoration: none;
            text-align: center;
        }
        
        li>a:first-child {
            background-color: green;
            transform: translateZ(25px); /*向Z轴方向移动25px*/
        }
        
        li>a:last-child {
            background-color: orange;
            transform: rotateX(90deg) translateZ(25px);/*X轴正轴方向旋转90°且Z轴正方向平移25px*/
        }
        
        li:hover {
            transform: rotateX(-90deg);
        }
    </style>
</head>

<body>
    <div class="nav">
        <ul>
            <li>
                <a href="###">首页</a>
                <a href="###">Home</a>
            </li>
            <li>
                <a href="###">首页</a>
                <a href="###">Home</a>
            </li>
            <li>
                <a href="###">首页</a>
                <a href="###">Home</a>
            </li>
            <li>
                <a href="###">首页</a>
                <a href="###">Home</a>
            </li>
        </ul>
    </div>
</body>

</html>

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值