Friday, 27 March 2015
Create a Sticky navigation bar in Blogger
Change Any normal Navigation bar to a Sticky Navigation Bar with this guide.
What is the benefits of this?
Your website or blog visitors doesn't have to scroll back to the top to select different topic or category.
Tutorial 1:
This tutorial helps to make your navigation bar appear at the top of your blog on load and fixed to the top of the browser window while the user is scrolling.
NOTE:This tutorial is for those who doesn't have navigation bar below header.
1.First of all login to your blog and go into Template>Edit Template
2.You’ll need to wrap it in a div with the id
navigationbar
like s(if your navigation bar has search box and social media icons the add their code also in it)
3. Go to Template > Edit HTML and search for
<div id="navigationbar"> ... /Your Navigation bar html goes here/ ... </div>
]]> </b:skin> and just
above ]]> </b:skin>
add the following code –
/* START thegeekystuff and hackersofhell FIXED NAV BAR */ #navigationbar { position: fixed; top: 0px; left: 0px; z-index: 999; width:100%;} /* END
thegeekystuff and hackersofhell
FIXED NAV BAR */
Tutorial 2:(recommended)
If your navigation bar is under your header and you want it to stick to the top of the window when user scroll past it then follow this tutorial is for you.
1. Go to Template > Customise > Advanced > Add CSS and add the following code. When you add CSS to the Template Designer on Blogger, it automatically gets placed before
]]></b:skin>
in your template.2.Now go into Template>Edit html and find the navigation bar code of your template.After finding,Paste/* START thegeekystuff and Hackersofhell STICKY NAV BAR */ sticknav { background: #ffffff; height: 30px; width: 100%; margin-right: 0px; margin-left: 0px; left: 0px; right: 0px; position: relative; z-index: 9999; } .fixed { position:fixed;} /* END
thegeekystuff and Hackersofhell
STICKY NAV BAR */
<sticknav>
before it and </sticknav>
after the whole navigation bar html code.(if your navigation bar has search box and social media icons the add their code also in it)
<sticknav>
.../Your template navigation code goes here/....
</sticknav>
4. The final step is to add a script to tell the bar to scroll. For this go to Layout > Add Gadget > HTML/Javascript Gadget and paste the following.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var aboveHeight = $('header').outerHeight();
$(window).scroll(function(){
if ($(window).scrollTop() > aboveHeight){
$('sticknav').addClass('fixed').css('top','0').next().css('padding-top','60px');
} else {
$('sticknav').removeClass('fixed').next().css('padding-top','0');
}
});
});
</script>
5.Save it and see variation into your blogSharing is Sexy! Share this post!
Subscribe to:
Post Comments
(
Atom
)
This comment has been removed by the author.
ReplyDeletethis method worked for my blogger site... https://www.logicaltube24.com
ReplyDeleteIt worked thanks!
ReplyDeleteHi, Thanks for the code and it worked very nice for my blog https://www.tekfiz.com. But one thing it is lacking. Is it possible to keep the logo by the left side of the "Sticky Menu" bar? I was looking for a tweak but unable to fix it. Could you please provide a code to make the logo appear on the left of the sticky menu bar which will make it even better?
ReplyDeleteAlso I can see your blog also having the same floating sticky menu bar without logo. Let me know if this can be fixed.