<div class="content"> <header class="menu"> <div class="logo-box"> <a href="/" title="首页" class="logo"> <img src="/img/logo/logo.png" class="before" alt="logo"> <img src="/img/logo/logo-1.png" class="after" alt="logo"> </a> </div> </header> <div style="width: 100%;height: 200vh;border: 1px solid red;"> <img src="img/banner/banner1.jpg" style="width: 100%; height: 100vh" alt=""> </div> </div>
.menu{ display: flex; transition: all .3s ease-in-out; width: 100%; top: 0; left: 0; right: 0; z-index: 10; position: fixed; padding: 10px 10px; height: 80px; align-items: center; transition: all .3s ease-in-out; } .menu.on{ opacity: 1; background: #ffffff; color: #000000; box-shadow: 0px 0px 10px 1px rgba(0, 0, 0, .15); } .menu .logo { width: 160px; height: 30px; line-height: 80px; position: relative; display: block; } .menu .logo img { -webkit-transition: all .3s ease-in-out; transition: all .3s ease-in-out; position: absolute; left: 0; top: 0; max-width: 100%; display: block; } .menu .logo .before { margin-top: -10px; visibility: visible; -webkit-clip-path: inset(0% 0 0% 0); clip-path: inset(0% 0 0% 0); } .menu.on .logo .before { visibility: hidden; -webkit-clip-path: inset(50% 0 50% 0); clip-path: inset(50% 0 50% 0); } .menu .logo .after { visibility: hidden; -webkit-clip-path: inset(50% 0 50% 0); clip-path: inset(50% 0 50% 0); } .menu.on .logo .after { visibility: visible; -webkit-clip-path: inset(0% 0 0% 0); clip-path: inset(0% 0 0% 0); }
$(document).ready(function () { $(window).scroll(function () { var winwidth = $(document).width(); var wintop = $(window).scrollTop(); // 已滚动卷去的高度 if (wintop > 20) { $(".menu").addClass("on"); } else { $(".menu").removeClass("on"); } }); });
本文为Jsky原创文章,转载无需和我联系,但请注明来自Jsky博客 www.tjin.link