×

推荐一个简单的酷炫导航

作者:andy0012017.01.06来源:Web前端之家浏览:17129评论:0
关键词:导航html

推荐一个简单的酷炫导航

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.     <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
  7.     <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  8.     <meta name="apple-mobile-web-app-capable" content="yes">
  9.     <meta name="format-detection" content="telephone=no">
  10.     <title>首页</title>
  11. </head>
  12. <style>
  13. body,
  14. p,
  15. ul,
  16. h1,
  17. h2,
  18. h3,
  19. h4,
  20. h5,
  21. h6,
  22. ol,
  23. dd,
  24. dl,
  25. input,
  26. li,
  27. span {
  28.     margin: 0;
  29.     padding: 0;
  30.     list-style: none;
  31.     font-weight: normal;
  32.     -webkit-tap-highlight-color: rgba(0,0,0,0);/*清除默认点击闪动效果*/
  33. }
  34. span{
  35.     display:inline-block;
  36. }
  37. i{
  38.     font-style:normal;
  39. }
  40. {
  41.     text-decoration: none;
  42.     color: inherit;
  43. }
  44. body {
  45.   font: 10px / 1.14 "Microsoft YaHei","Helvetica Neue",Helvetica,Arial,sans-serif;
  46.   /*font: 10px / 1.14 effra,Helvetica,Arial,sans-serif;*/
  47.   color:#333;
  48.   -webkit-font-smoothing: antialiased;
  49.   -moz-osx-font-smoothing: grayscale;
  50.   -moz-font-feature-settings: 'liga', 'kern';
  51.     /*消除文字锯齿*/
  52. }
  53. html{font-size:10px}/*默认配置*/
  54. @media screen and (min-width:321px) and (max-width:375px){html{font-size:11px}}
  55. @media screen and (min-width:376px) and (max-width:414px){html{font-size:12px}}
  56. @media screen and (min-width:415px) and (max-width:639px){html{font-size:15px}}
  57. @media screen and (min-width:640px) and (max-width:719px){html{font-size:20px}}
  58. @media screen and (min-width:720px) and (max-width:749px){html{font-size:22.5px}}
  59. @media screen and (min-width:750px) and (max-width:799px){html{font-size:23.5px}}
  60. @media screen and (min-width:800px){html{font-size:25px}}
  61. .clearfix:after {
  62.     content: ".";
  63.     display: block;
  64.     height: 0;
  65.     visibility: hidden;
  66.     clear: both;
  67. }
  68. .clearfix {
  69.     *zoom: 1;
  70. }
  71. .nav{
  72.     width: 100%;
  73.     height: 100%;
  74.     position: absolute;
  75.     left: 0;
  76.     top: 0;
  77.     display: none;
  78.     overflow: hidden;
  79.     z-index:2;
  80. }
  81. .nav:before{
  82.     content: '';
  83.     position: absolute;
  84.     width: 100%;
  85.     height: 100%;
  86.     background: #333;
  87.     opacity:.5;
  88.     z-index: -1;
  89. }
  90. .nav>ul{
  91.     position: absolute;
  92.     width: 100%;
  93.     height: 100%;
  94. }
  95. .nav>ul>li{
  96.     float: left;
  97.     width: 25%;
  98.     height: 100%;
  99.     transition: all .2s;
  100.     position: relative;
  101.     cursor: pointer;
  102.     display: block;
  103.     background: #2c3739;
  104. }
  105. .nav>ul>li:nth-child(2n){
  106.     top: -100%;
  107. }
  108. .nav>ul>li:nth-child(2n+1){
  109.     top: 100%;
  110. }
  111. .nav>ul>li:before{
  112.     content: '';
  113.     position: absolute;
  114.     width: 2px;
  115.     height: 100%;
  116.     background: #fb565e;
  117.     left: 0;
  118.     transform: rotate(10deg);
  119. }
  120. .nav>ul>li:first-of-type:before{
  121.     width: 0;
  122. }
  123. .nav>ul>li:last-of-type{
  124.     border-right: 0;
  125. }
  126. .nav>ul>li.open{
  127.     width: 58%;
  128. }
  129. .nav>ul>li.hide{
  130.     width: 14%;
  131. }
  132. .nav .nav-inner{
  133.     position: absolute;
  134.     width: 100%;
  135.     height: 100%;
  136.     left: 0;
  137.     vertical-align: middle;
  138.     text-align: center;
  139.     color: #007aff;
  140. }
  141. .nav .nav-inner>span{
  142.    position: absolute;
  143.     top: 45%;
  144.     left: 40%;
  145.     background:#fff;
  146.     width: 3rem;
  147.     height: 3rem;
  148.     border-radius: .3rem;
  149. }
  150. .nav .nav-inner>span:before{
  151.     font-size: 3rem;
  152. }
  153. .nav>ul>li.open .nav-inner>span{
  154.     left: 20%;
  155.     top: 30%;
  156. }
  157. .nav>ul>li.open .nav-inner>span:before{
  158.     font-size: 4rem;
  159. }
  160. .nav>ul>li.open .nav-inner>h3{
  161.     display: block;
  162.     position: absolute;
  163.     font-size: 40px;
  164.     color: #fb565e;
  165.     top: 33%;
  166.     left: 50%;
  167. }
  168. .nav>ul>li .nav-inner>h3{
  169.     display: none;
  170. }
  171. .nav>ul>li.open .nav-inner>p{
  172.     font-size: 20px;
  173.     color: #fff;
  174.     text-align: center;
  175.     position: relative;
  176.     left: 0;
  177.     padding:0 100px;
  178.     line-height: 1.5;
  179.     top: 51%;
  180. }
  181. .nav>ul>li .nav-inner>p{
  182.     display: none;
  183. }
  184. /*banner*/
  185. .banner{
  186.     width: 100%;
  187.     height: 100%;
  188.     position: absolute;
  189.     z-index:1;
  190.     padding: 10px;
  191.     font-size:3rem;
  192.     background: url("../images/banner-02.jpg") no-repeat center center;
  193.     background-size: cover;
  194. }
  195. </style>
  196. <body>
  197. <div>
  198.     <div>
  199. homepage (click)
  200.     </div>
  201.     <div>
  202.         <ul id="navs">
  203.             <li>
  204.                 <div>
  205.                     <span></span>
  206.                     <h3>alarm</h3>
  207.                     <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>
  208.                 </div>
  209.             </li>
  210.             <li>
  211.                 <div>
  212.                     <span></span>
  213.                     <h3>audio</h3>
  214.                     <p>balabala xiaomoxian</p>
  215.                 </div>
  216.             </li>
  217.             <li>
  218.                 <div>
  219.                     <span></span>
  220.                     <h3>contacts</h3>
  221.                     <p>bilibili</p>
  222.                 </div>
  223.             </li>
  224.             <li>
  225.                 <div>
  226.                     <span></span>
  227.                     <h3>share</h3>
  228.                     <p>hello word!</p>
  229.                 </div>
  230.             </li>
  231.         </ul>
  232.     </div>
  233. </div>
  234. </body>
  235. </html>
  236. <script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
  237. <script>
  238.     $(document).ready(function () {
  239.         function navIndex(){
  240.             setTimeout(function(){
  241.                 $(document).on('mouseover mouseleave','#navs>li',function(e){
  242.                     if(e.type=='mouseover'){
  243.                         $(this).addClass('open').siblings().addClass('hide');
  244.                         $(this).find('p').stop().fadeIn();
  245.                     }else if(e.type=='mouseleave'){
  246.                        $(this).removeClass('open').siblings().removeClass('hide');
  247.                        $(this).find('p').hide();
  248.                     }
  249.                 });
  250.             },500)
  251.         }
  252.         $(document).on('click','.banner',function(){
  253.             $('.nav').show().find('li').each(function(e,i){
  254.                 $(i).animate({'top':0},e*100,function(){
  255.                     navIndex()
  256.                 })
  257.             })
  258.         })
  259.     });
  260. </script>

您的支持是我们创作的动力!
温馨提示:本文作者系 ,经Web前端之家编辑修改或补充,转载请注明出处和本文链接:
https://jiangweishan.com/article/biji013.html

网友评论文明上网理性发言 已有0人参与

发表评论: