|
用js实现导航鼠标放置主菜单后显示所有子菜单方法提前必须引入SuperSlide
类似下面截图
css部分:
- nav { height: 40px; }
- .nav_wrap { height: 40px; line-height: 40px; }
- .nav_item { position: relative; margin-right: 10px; }
- .nav_item span a { font-size: 14px; color: #000; display: block; padding: 0 15px; text-align: center; }
- .nav_item_r { float: right; background: #e8b856; border-radius: 6px; position: absolute; top: -3px; right: 0; }
- .nav_item_r span a { line-height: 58px; height: 58px; }
- .sub { background: #fff; background: rgba(255,255,255,0.97); box-shadow: 0 20px 30px rgba(0,0,0,.1); position: absolute; display: none; z-index: 9; left: 0; border-radius:0 10px 10px 10px; }
- .sub_index { position: absolute; }
- .sub_wrap { min-width: 170px; min-height: 100px; padding:15px 20px 15px 30px; position: relative; }
- .sub_wrap a { display: block; line-height: 20px; float: left; width: 45%; margin:8px 5% 8px 0;}
- .nav_item { position:relative; transition:0.1s all linear; cursor:pointer; float: left; margin-top: 33px;}
- .nav_item::before {content:""; position:absolute; bottom:0px; left:100%; width:0; height:3px;background: #ff7c24; transition:0.1s all linear;}
- .nav_item:hover::before { width:100%; bottom:0px; left:0; transition-delay:0.1s; }
- .nav_item:hover ~ li::before {left:0;}
- .nav_item:active {background:rgba(0,0,0,0.1);color:#fff;}
- .nav_mobile { font-size: 12px; cursor: pointer; margin-right: 0; margin-left:10px;}
- .nav_mobile span a { padding: 0!important; font-size: 12px; }
- .sub_mobile { padding: 10px 5px; border-radius: 10px; line-height: 20px; text-align: center; left: 50%; margin-left: -60px; }
- .sub_mobile_itme { width: 100px; padding:0 5px; }
- .sub_mobile img { width: 100%; }
- .sub_mobile span { margin-top: 4px; display: block; color: #666; }
- .nav_mobile em { margin-right: 4px; font-size: 12px; }
- /**/
- .nav2 {float: left; }
- .nav2 .nav_wrap { line-height: 50px; height: 50px; position: relative; }
- .nav2 .nav_item span a { font-size: 16px; }
- .nav3 { height: 50px; }
- .nav3 li { float: left; }
复制代码 html部分:
- <nav id="nav" class="nav2">
- <div class="in_nav main">
- <ul class="nav_wrap">
- <li class="nav_item nli ts fl">
- <span><a href="/" target="_blank" title="网站首页">首页</a></span>
- </li>
- <li class="nav_item nli ts fl">
- <span><a href="/" target="_blank" title="主菜单">主菜单</a></span>
- <div class="sub sub_index">
- <div class="sub_wrap">
- <a href="/" target="_blank" title="子菜单1"><span>子菜单1</span></a>
- <a href="/" target="_blank" title="子菜单2"><span>子菜单2</span></a>
- <a href="/" target="_blank" title="子菜单3"><span>子菜单3</span></a>
- <div class="clear"></div>
- </div>
- </div>
- </li>
- </ul>
- </div>
- </nav>
复制代码 js:
- $(function(){
- jQuery("#nav").slide({ type:"menu", titCell:".nli", targetCell:".sub",effect:"slideDown",delayTime:100,triggerTime:0,returnDefault:true});
- });
复制代码
|
上一篇:<meta name=“renderer“ content=“webkit“>的作用下一篇:Nginx配置伪静态404,Apache出现File not found.
|