Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
/*** Mixins & Default Styles ***/ * { box-sizing: border-box; margin: 0; padding: 0; } body { overflow-x: hidden; overflow-y: scroll; } /*** Color Variables ***/ /*** Centering Hack ***/ /*** Header Styles ***/ header { width: 100vw; height: 100vh; background: #5661f2; display: flex; } /*** Navigation Styles ***/ nav { width: 100vw; height: 160px; background: #46b2f0; display: grid; grid-template-columns: 1fr 1fr; position: fixed; z-index: 10; transition: all 0.3s; } nav.navShadow { box-shadow: 0 4px 30px -5px rgba(0, 0, 0, 0.2); height: 100px; } nav.navShadow #word-mark { opacity: 0; } #brand, #menu, ul { display: flex; align-items: center; } #brand { padding-left: 40px; } #logo { width: 55px; height: 55px; background: #fff; border-radius: 50%; cursor: pointer; } #word-mark { width: 120px; height: 20px; background: #fff; border-radius: 90px; margin-left: 20px; opacity: 1; transition: all 0.3s; } /*** Menu Styles ***/ #menu { justify-content: flex-end; padding-right: 40px; } li { margin-left: 20px; } li a { width: 80px; height: 20px; background: #fff; display: block; border-radius: 90px; } #menu-toggle { width: 55px; height: 55px; background: #2ea8ee; display: flex; justify-content: center; align-items: center; border-radius: 50%; cursor: pointer; display: none; } #menu-toggle:hover .bar { width: 25px; } #menu-toggle.closeMenu .bar { width: 25px; } #menu-toggle.closeMenu .bar:first-child { transform: translateY(7px) rotate(45deg); } #menu-toggle.closeMenu .bar:nth-child(2) { transform: scale(0); } #menu-toggle.closeMenu .bar:last-child { transform: translateY(-7px) rotate(-45deg); } .bar { width: 25px; height: 2px; background: #fff; transition: 0.3s ease-in-out; } .bar:nth-child(2) { width: 20px; margin: 5px 0; } .bar:last-child { width: 15px; } /*** Hero Section Styles ***/ #hero-section { width: 100vw; height: calc(100vh - 160px); display: flex; justify-content: center; align-items: center; margin-top: 160px; } #head-line { width: 520px; height: 30px; background: #fff; border-radius: 90px; position: relative; } #head-line:before, #head-line:after { content: ""; height: 30px; border-radius: 90px; } #head-line:before { width: 360px; background: #fff; position: absolute; top: -60px; left: 50%; transform: translate(-50%, 0); } #head-line:after { width: 200px; background: #fff; position: absolute; left: 50%; bottom: -60px; transform: translate(-50%, 0); } /*** Section Styles ***/ section { width: 100vw; height: calc(100vh - 100px); display: flex; justify-content: center; } section:nth-child(odd) { background: #fa6c98; } section:nth-child(even) { background: #79edfc; } #heading { width: 120px; height: 20px; background: #fff; border-radius: 90px; margin-top: 40px; } /*** Responsive Menu For Smaller Device ***/ @media screen and (max-width: 767px) { #menu-toggle { display: flex; } ul { display: inline-block; width: 100vw; height: 0; background: #79edfc; position: absolute; top: 160px; transform: translate(, ); box-shadow: 0 5px 30px -4px rgba(0, 0, 0, 0.2); transition: all 0.3s; } ul.showMenu { height: 250px; } ul.showMenu li { height: 80px; opacity: 1; visibility: visible; } li { width: 50%; height: 80px; float: left; padding-left: 40px; opacity: 0; visibility: hidden; margin-left: 0; transition: all 0.3s 0.1s; } li:first-child, li:nth-child(2) { margin-top: 80px; } #head-line { transform: scale(0.8); } }
JavaScript
$( () => { //On Scroll Functionality $(window).scroll( () => { var windowTop = $(window).scrollTop(); windowTop > 100 ? $('nav').addClass('navShadow') : $('nav').removeClass('navShadow'); windowTop > 100 ? $('ul').css('top','100px') : $('ul').css('top','160px'); }); //Click Logo To Scroll To Top $('#logo').on('click', () => { $('html,body').animate({ scrollTop: 0 },500); }); //Smooth Scrolling Using Navigation Menu $('a[href*="#"]').on('click', function(e){ $('html,body').animate({ scrollTop: $($(this).attr('href')).offset().top - 100 },500); e.preventDefault(); }); //Toggle Menu $('#menu-toggle').on('click', () => { $('#menu-toggle').toggleClass('closeMenu'); $('ul').toggleClass('showMenu'); $('li').on('click', () => { $('ul').removeClass('showMenu'); $('#menu-toggle').removeClass('closeMenu'); }); }); });
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>jQuery平滑滚动的粘性导航菜单-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号