Labels

php (35) javascript (31) phpjavascript (30) jquery (23) html (20) mysql (14) database (9) codeigniter (4) json (4) bar chart (2) calendar (2) column chart (2) framework (2) google maps (2) query (2) tables (2) url (2) dropdown (1)

Sunday, July 8, 2018

Hide navbar when user starts to scroll the page down using javascript

Hide a navbar when the user starts to scroll the page using javascript

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
background-color: orange;
font-family: Arial, Helvetica, sans-serif;
}
#navbar {
background-color: #333;
position: fixed;
top: 0;
width: 100%;
display:block;
transition: top 0.3s;
}
#navbar a {
float: left;
display: block;
color: red;
text-align: center;
padding: 15px;
text-decoration: none;
font-size: 17px;
}
#navbar a:hover {
background-color: green;
color: orange;
}
</style>
</head>
<body>
<div id="navbar">
<a href="#home">Home</a>
<a href="#news">News</a>
<a href="#news">About Us</a>
<a href="#news">Contact Us</a>
<a href="#news">Sitemap</a>
</div>
<div style="padding:15px 15px 2500px;font-size:30px;margin-top:30px;">
<p><b>This example demonstrates how to hide a navbar when the user starts to scroll the page.</b></p>
<p>Scroll down this frame to see the effect!</p>
<p>Scroll up to show the navbar.</p>
</div>
<script>
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-50px";
}
prevScrollpos = currentScrollPos;
}
</script>
</body>
</html>

Result:



58 comments:

  1. Supertech E Square is a great mix of commercial, retail and entertainment offering well place by Supertech Limited at Sector 96, Noida.

    ReplyDelete
  2. ‘Sodom’ in the Garden City: Coded Port Harcourt hangout where rich, horny women hire men for s3x discovered
    ‘Sodom’ in the Garden City: Coded Port Harcourt hangout where rich, horny women hire men for s3x discovered

    A coded joint in Port Harcourt, the Rivers state capital where men and women go to hire men to give them good quality s3x has been discovered.

    The name Port Harcourt represents many things to diverse individuals.


    Read More @ Horny Women hire men for s3x discovered

    ReplyDelete
  3. As students’ college loan debt grows, How much student loan debt is too much?

    With more students attending college, and taking on debt to do it, the nation’s outstanding student loan debt grew by 2.1 percent, to $1.41 trillion, from $1.38 trillion at year-end 2017, according to the Federal Reserve Bank of New York.
    Loans can have some unexpected benefits Read More @

    How much student loan debt is too much?

    ReplyDelete
  4. Your attention to detailed information puts you at the top.
    You are an inspiration to us.
    Web Designing company in kolkata
    psd template/game download/blogs

    ReplyDelete
  5. Hi, So much Thanks for the share. It was very helpful to us. Very informative post.

    ReplyDelete
  6. I Am So Happy To Read This. This Is The Kind Of Manual That Needs To Be Given And Not The Random Misinformation That's At The Other Blogs.

    ReplyDelete
  7. Nice post.
    If you are roadrunner email user and want your Roadrunner Email Password Reset then call roadrunner email helpline +1-888-338-6033.

    ReplyDelete
  8. A debt of gratitude is in order for composing a brilliant article and I got extremely intriguing by understanding It has the most enlightening well ordered directions I have read.If you have any inquiry with Norton then you call our number+18555583999.

    ReplyDelete
  9. pls i want to learn php, jave scrip, and bootstrap factworld.com.ng

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Really helpful post to hide navigation bar for android application development ...thanks for sharing that kind of codes.
    mobile application development company in UK

    ReplyDelete
  12. This comment has been removed by the author.

    ReplyDelete
  13. The online courses offered provide sufficient detail about marketing as well as provide complete detail to measure the program properly with the help of browsers and customers that are eventually provided to the student to enhance their level of knowledge.

    marketing agencies in singapore

    ReplyDelete
  14. Social media marketing allows your customers to get to know your interests in ways they never would otherwise. It humanizes you and highlights the commonalities shared with others. People want to buy merchandise and do business with people like them in their neighborhoods.

    marketing courses in singapore

    ReplyDelete
  15. Your article is easy to understand, simple communication is accessible to most people. I will keep track of your posts regularly
    hotmail login

    ReplyDelete
  16. Hi, i read your blog from time to time and i own a similar one and i was just wondering if you get a lot of spam comments? If so how do you protect against it, any plugin or anything you can advise? I get so much lately it's driving me crazy so any help is very much appreciated.kundli matching

    ReplyDelete
  17. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.

    ReplyDelete
  18. People want to buy merchandise and do business with people like them in their neighborhoods. Airtel bondho sim offer

    ReplyDelete
  19. nice article thanks for shearing

    ReplyDelete
  20. This comment has been removed by the author.

    ReplyDelete
  21. A well written perspective! Thanks for sharing this useful info.
    Website Designing Company Meerut

    ReplyDelete
  22. This is really impressible post for everyone to know about this matter. I am so glad to read this. Thank you so much for sharing your helpful experience.

    If you want know more please visitFashion



    ReplyDelete

  23. Its really feeling great as our hard work is helping someone. Thanks for visiting our blog.
    More effective blog

    ReplyDelete
  24. The effectiveness of marketing tools will also have to be monitored to ensure that the approach continues to be fruitful. There are a number of site optimization and email marketing tools that are available today. Careful analysis and selection of internet marketing strategies will help ensure business success.

    seo company singapore

    ReplyDelete
  25. Nice Article for freelancers. Thanks for writing such a good article in the form of tips for freelancing jobs.

    ReplyDelete
  26. This is a very impressive post thanks dear! do you want dofollow backlink from my website? just comment on my post related! Wafi Apps

    ReplyDelete
  27. This is important as who can really tell from lying on it in a store if it will be right for you for a whole night. My friends thought they wanted a firm mattress but are miserable on it and didn't buy from a store that would let them return it.

    Joe Davies

    ReplyDelete
  28. nice blog! it's interesting. thank you for sharing.

    womens denim shirt

    ReplyDelete
  29. I have always admired your site, Thanks for the great tips and work .
    Web Design and Development Oman

    ReplyDelete
  30. Slides taken today maybe have the best chance of being viewable in 100 years as all you need to do is hold it up to the light.

    seo agency singapore

    ReplyDelete
  31. Hello,
    I really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people.
    Digital Marketing Agency in India

    ReplyDelete
  32. Hello, I have read your post and it is good to me.
    I have a site you can follow it https://www.grandgatewayhotel.com/

    ReplyDelete
  33. Hello, I have read your post and it is good to me.
    I have a site you can follow it https://www.grandgatewayhotel.com/

    ReplyDelete
  34. Hello, I have read your post and it is good to me.
    I have a site you can follow it https://www.grandgatewayhotel.com/

    ReplyDelete
  35. Thanks for sharing this interesting and informative post. This blog is very helpful for me.

    register a private company in india

    ReplyDelete
  36. Hello , I have already visit your post . It’s really good for me . I have a site you can follow this http://www.hotels4humanity.com
    Thank you.

    ReplyDelete
  37. Your selection of topic is very good and also well written. Thanks for sharing. I feel like all your ideas are incredible! Great job!!!
    http://www.prestigelakeridgebangalore.co.in/
    http://www.mantriserenitykanakapuraroad.in/
    http://www.prestigefalconcitykanakapuraroad.in/
    http://www.godrejairhoodi.co/
    http://www.goyalorchidwhitefield.net/
    http://www.prestigewillowtree.co/

    ReplyDelete
  38. Great post! Thanks for sharing this amazing post. visit: Gujarati News

    ReplyDelete
  39. Shophoop is an online site that offers products like Printer & Scanner and many other devices for purchase to the customers at really reasonable prices. There are products like all types of printers, desktops and their peripheral devices, Computers & Tablets headphones, speakers, printers, laptops, cameras, tablets, computer accessories, computer components, chromebooks etc. Customers can buy from about 1.5 million products on Shophoop. Displayed products on Shophoop has been categorized into various groups on the basis of different criteria that makes selection of desired product for the customers much easier.
    Computers & Tablets
    Printer & Scanner
    Bags & Carry cases

    ReplyDelete

More Posts

FOLLOW