javascript - Make navbar responsive without changing custom css and effects -
i created site using jekyll
, used this theme. however, problem site navbar has links, not collapse when opening website in mobile. in all, navbar not responsive @ all. want make responsive, without changing css. should do? site has bootstrap
, jquery
included.
this header html code:
<header class="site-header"> <div class="container"> <a id="site-header-brand" href="/" title="xyz"> site title </a> <nav class="site-header-nav" role="navigation"> <a href="/" class=" site-header-nav-item hvr-underline-from-center" target="" title="home"> home </a> </nav> </div> </header>
and here css:
.site-header{ padding-top:20px; padding-bottom:20px; width: 100%; position: fixed; margin: 40px 0 30px 0; top: 0; left: 0 !important; right: 0; z-index: 103; color: #000; background: #fff; -webkit-transition: 0.5s ease; -moz-transition: 0.5s ease; -ms-transition: 0.5s ease; -o-transition: 0.5s ease; transition: 0.5s ease; } .site-header-nav{ float:right; margin-bottom: -20px; } .site-header-nav-item { color: #000; display:inline-block; padding:10px; margin-left:1.25rem; font-size: 20px; } .site-header { box-shadow: 0 0 5px rgba(0,0,0,0.1); } .site-header.site-header-nav-scrolled { margin: 0; background-color: white; -webkit-box-shadow: 0 0.125em 0.125em 0 rgba(0, 0, 0, 0.125); -moz-box-shadow: 0 0.125em 0.125em 0 rgba(0, 0, 0, 0.125); -ms-box-shadow: 0 0.125em 0.125em 0 rgba(0, 0, 0, 0.125); -o-box-shadow: 0 0.125em 0.125em 0 rgba(0, 0, 0, 0.125); box-shadow: 0 0.125em 0.125em 0 rgba(0, 0, 0, 0.125); }
the javascript scroll function:
$(window).scroll(function () { var scrollpos = $(this).scrolltop(); if ($(window).scrolltop() > 55) { $('.site-header').addclass('site-header-nav-scrolled'); } else { $('.site-header').removeclass('site-header-nav-scrolled'); } });
you need create navbar collapse button , wrap links in button when in mobile. there great example @ bootstrap how this.
Comments
Post a Comment