CSS3实现简单的翻转菜单效果

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>翻转菜单效果</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .nav{
            width: 400px;
            height: 40px;
            margin: 0 auto;
            margin-top: 100px;
            background-color: yellow;
        }
        .nav>li{
            list-style: none;
            float: left;
            width: 120px;
            height: 40px;
            background-color: #purple;
            margin-left: 10px;
            text-align: center;
            line-height: 40px;
            position: relative;
        }
        .sub{
            /*不显示元素*/
            /*display: none;*/
            width: 120px;
            position: absolute;
            left: 0;
            top: 40px;
        }
        .sub li{
            list-style: none;
            background-color: deeppink;
            /*使其默认为反的,旋转时正*/
            transform: rotateY(180deg);
            transition: all 1s;
			/*设置透明度*/
            opacity: 0;
        }
        /*
        .nav>li:hover .sub{
            display: block;
        }
        */
        .nav>li:hover .sub li{
            transform: none;
            opacity: 1;
        }
        .nav>li:hover .sub li:nth-child(1){
            transition-delay: 0ms;
        }
        .nav>li:hover .sub li:nth-child(2){
            transition-delay: 200ms;
        }
        .nav>li:hover .sub li:nth-child(3){
            transition-delay: 400ms;
        }
        .nav>li:hover .sub li:nth-child(4){
            transition-delay: 600ms;
        }
        .nav>li:hover .sub li:nth-child(5){
            transition-delay: 800ms;
        }

        .nav>li .sub li:nth-child(5){
            transition-delay: 0ms;
        }
        .nav>li .sub li:nth-child(4){
            transition-delay: 200ms;
        }
        .nav>li .sub li:nth-child(3){
            transition-delay: 400ms;
        }
        .nav>li .sub li:nth-child(2){
            transition-delay: 600ms;
        }
        .nav>li .sub li:nth-child(1){
            transition-delay: 800ms;
        }
        div{
            width: 400px;
            height: 300px;
            background-color: #990022;
            margin: 0 auto;
        }
    </style>
</head>
<body>
<ul class="nav">
    <li>一级菜单
        <ul class="sub">
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
        </ul>
    </li>
    <li>一级菜单
        <ul class="sub">
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
        </ul>
    </li>
    <li>一级菜单
        <ul class="sub">
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
            <li>二级菜单</li>
        </ul>
    </li>
</ul>
<div><br/><h2>这里写下主页的内容</h2></div>
</body>
</html>

阅读更多
个人分类: html/xml/javaScript/css
上一篇JavaScript的一些操作
下一篇初识GIT
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭