3D导航栏

看到别人的网站上面那些3D的导航栏效果你羡慕了吗?接下来就由我来教你怎么写属于自己的3D导航栏效果吧,想学的快来围观吧!

html代码:
<body>
    <ul>
        <li>
            <div class="box">
                <div class="front">菜单一</div>
                <div class="bottom">菜单1</div>
            </div>
        </li>
        <li>
            <div class="box">
                <div class="front">菜单二</div>
                <div class="bottom">菜单2</div>
            </div>
        </li>
        <li>
            <div class="box">
                <div class="front">菜单三</div>
                <div class="bottom">菜单3</div>
            </div>
        </li>
        <li>
            <div class="box">
                <div class="front">菜单四</div>
                <div class="bottom">菜单4</div>
            </div>
        </li>
        <li>
            <div class="box">
                <div class="front">菜单五</div>
                <div class="bottom">菜单5</div>
            </div>
        </li>
    </ul>
</body>
css代码:
* {
            margin: 0;
            padding: 0;
        }
        
        ul {
            margin: 100px;
        }
        
        ul li {
            width: 120px;
            height: 35px;
            list-style: none;
            float: left;
            margin: 0 5px;
            /* 透视 */
            perspective: 500px;
        }
        
        .box {
            width: 100%;
            height: 100%;
            /* 立体空间保留 */
            transform-style: preserve-3d;
            /* 过渡效果 */
            transition: all .4s;
        }
        
        .box:hover {
            /* 鼠标移入box沿着x轴旋转180度 */
            transform: rotateX(90deg);
            cursor: pointer;
        }
        
        .box:hover .bottom {
            /* 添加阴影 */
            box-shadow: 2px 2px 2px #ccc;
        }
        
        .front,
        .bottom {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            text-align: center;
            line-height: 35px;
        }
        
        .front {
            background-color: #ccc;
            z-index: 1;
            /* 沿着z轴移动17.5px 盒子向前移动 */
            transform: translateZ(17.5px);
        }
        
        .bottom {
            background-color: #999;
            /* x轴一定是负值   向下移动(如果有移动必须先写移动) */
            transform: translateY(17.5px) rotateX(-90deg);
        }
效果图:

效果图展示
以上代码就是导航栏3D效果了,看完以上代码你是否有新的思路能够完成这个小案例呢?如果有可否分享给我呢?我们一起学习吧!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值