简单的动态导航

wishuice
wishuice 发布于 2017-01-04 17:23:38 浏览:2028 类型:原创 - 随笔 分类:HTML/CSS - css 二维码: 作者原创 版权保护
写个笔记就和改bug一样麻烦
<!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,maximum-scale=1.0,user-scalable=0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <title>首页</title>
</head>
<style>
body,
p,
ul,
h1,
h2,
h3,
h4,
h5,
h6,
ol,
dd,
dl,
input,
li,
span {
    margin: 0;
	padding: 0;
	list-style: none;
	font-weight: normal;
    -webkit-tap-highlight-color: rgba(0,0,0,0);/*清除默认点击闪动效果*/
}
span{
	display:inline-block;
}
i{
	font-style:normal;
}
a {
	text-decoration: none;
	color: inherit;
}
body {
  font: 10px / 1.14 "Microsoft YaHei","Helvetica Neue",Helvetica,Arial,sans-serif;
  /*font: 10px / 1.14 effra,Helvetica,Arial,sans-serif;*/
  color:#333;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -moz-font-feature-settings: 'liga', 'kern';
	/*消除文字锯齿*/
}
html{font-size:10px}/*默认配置*/
@media screen and (min-width:321px) and (max-width:375px){html{font-size:11px}}
@media screen and (min-width:376px) and (max-width:414px){html{font-size:12px}}
@media screen and (min-width:415px) and (max-width:639px){html{font-size:15px}}
@media screen and (min-width:640px) and (max-width:719px){html{font-size:20px}}
@media screen and (min-width:720px) and (max-width:749px){html{font-size:22.5px}}
@media screen and (min-width:750px) and (max-width:799px){html{font-size:23.5px}}
@media screen and (min-width:800px){html{font-size:25px}}
.clearfix:after {
	content: ".";
	display: block;
	height: 0;
	visibility: hidden;
	clear: both;
}
.clearfix {
	*zoom: 1;
}


.nav{
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    display: none;
    overflow: hidden;
    z-index:2;
}
.nav:before{
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background: #333;
    opacity:.5;
    z-index: -1;
}
.nav>ul{
    position: absolute;
    width: 100%;
    height: 100%;
}
.nav>ul>li{
    float: left;
    width: 25%;
    height: 100%;
    transition: all .2s;
    position: relative;
    cursor: pointer;
    display: block;
    background: #2c3739;
}
.nav>ul>li:nth-child(2n){
    top: -100%;
}
.nav>ul>li:nth-child(2n+1){
    top: 100%;
}
.nav>ul>li:before{
    content: '';
    position: absolute;
    width: 2px;
    height: 100%;
    background: #fb565e;
    left: 0;
    transform: rotate(10deg);
}
.nav>ul>li:first-of-type:before{
    width: 0;
}
.nav>ul>li:last-of-type{
    border-right: 0;
}
.nav>ul>li.open{
    width: 58%;
}
.nav>ul>li.hide{
    width: 14%;
}
.nav .nav-inner{
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    vertical-align: middle;
    text-align: center;
    color: #007aff;
}
.nav .nav-inner>span{
   position: absolute;
    top: 45%;
    left: 40%;
    background:#fff;
    width: 3rem;
    height: 3rem;
    border-radius: .3rem;
}
.nav .nav-inner>span:before{
    font-size: 3rem;
}
.nav>ul>li.open .nav-inner>span{
    left: 20%;
    top: 30%;
}
.nav>ul>li.open .nav-inner>span:before{
    font-size: 4rem;
}

.nav>ul>li.open .nav-inner>h3{
    display: block;
    position: absolute;
    font-size: 40px;
    color: #fb565e;
    top: 33%;
    left: 50%;
}
.nav>ul>li .nav-inner>h3{
    display: none;
}

.nav>ul>li.open .nav-inner>p{
    font-size: 20px;
    color: #fff;
    text-align: center;
    position: relative;
    left: 0;
    padding:0 100px;
    line-height: 1.5;
    top: 51%;
}
.nav>ul>li .nav-inner>p{
    display: none;
}
/*banner*/
.banner{
    width: 100%;
    height: 100%;
    position: absolute;
    z-index:1;
    padding: 10px;
    font-size:3rem;
    background: url("../images/banner-02.jpg") no-repeat center center;
    background-size: cover;
}
</style>
<body>
<div class="page">
    <div class="banner">
homepage (click)
    </div>
    <div class="nav">
        <ul class="clearfix" id="navs">
            <li>
                <div class="nav-inner">
                    <span class="icon"></span>
                    <h3>alarm</h3>
                    <p>Zero is the first banking experience to combine debit-style functionality and credit card rewards. Powered by a solid metal card called Zerocard and the Zero app, Zero gives customers 3.0% cash back on purchases and has none of the fees traditional banks charge.</p>
                </div>
            </li>
            <li>
                <div class="nav-inner">
                    <span class="icon"></span>
                    <h3>audio</h3>
                    <p>balabala xiaomoxian</p>
                </div>
            </li>
            <li>
                <div class="nav-inner">
                    <span class="icon"></span>
                    <h3>contacts</h3>
                    <p>bilibili</p>
                </div>
            </li>
            <li>
                <div class="nav-inner">
                    <span class="icon"></span>
                    <h3>share</h3>
                    <p>hello word!</p>
                </div>
            </li>
        </ul>
    </div>
</div>
</body>
</html>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
    $(document).ready(function () {
        function navIndex(){
            setTimeout(function(){
                $(document).on('mouseover mouseleave','#navs>li',function(e){
                    if(e.type=='mouseover'){
                        $(this).addClass('open').siblings().addClass('hide');
                        $(this).find('p').stop().fadeIn();
                    }else if(e.type=='mouseleave'){
                       $(this).removeClass('open').siblings().removeClass('hide');
                       $(this).find('p').hide();
                    }
                });
            },500)
        }
        $(document).on('click','.banner',function(){
            $('.nav').show().find('li').each(function(e,i){
                $(i).animate({'top':0},e*100,function(){
                    navIndex()
                })
            })
        })
    });
</script>
z
给个赞 22 人点赞
收藏 48 人收藏
评论 已有 10 条评论;以下用户言论只代表其个人观点,不代表 前端网(QDFuns) 的观点或立场。
登录 以后才能发表评论
最热评论
994399414
9943994142017-01-06 11:01:355F
大神,接受我的膝盖!!!
举报 支持 (1) 回复 (0)
最新评论
wishuice
wishuice7 天前10F
没有适配手机端 //@wwx4wqbb:但是你这个有个问题把?手机端肯定点不进去.
目测手机端只能出现在homepage(click)页面
举报 支持 (0) 回复 (0)
wwx4wqbb
wwx4wqbb2017-01-11 17:28:419F
大神,.请问有解决方法么?
举报 支持 (0) 回复 (0)
wwx4wqbb
wwx4wqbb2017-01-11 17:25:138F
但是你这个有个问题把?手机端肯定点不进去.
目测手机端只能出现在homepage(click)页面
举报 支持 (0) 回复 (1)
huahua_1994
huahua_19942017-01-09 09:39:037F
emoticon
举报 支持 (0) 回复 (0)
qq2020
qq20202017-01-08 13:25:086F
emoticon
举报 支持 (0) 回复 (0)
994399414
9943994142017-01-06 11:01:355F
大神,接受我的膝盖!!!
举报 支持 (1) 回复 (0)
wishuice
wishuice2017-01-05 17:28:544F
yes //@良民:这个红线并不是分界线。。div还是竖的吧。。
举报 支持 (0) 回复 (0)
良民
良民2017-01-05 17:15:273F
这个红线并不是分界线。。div还是竖的吧。。
举报 支持 (0) 回复 (1)
18334792877
183347928772017-01-05 15:54:152F
必须赞一个
举报 支持 (0) 回复 (0)
ddvbbk
ddvbbk2017-01-05 09:27:071F
哔哩哔哩。。。
举报 支持 (0) 回复 (0)
wishuice wishuice 作者

作者最新