Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked

Developer
Size
2,936 Kb
Views
8,096

How do I make an stop page jumping to top when sticky topbar menu icon is clicked?

Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked.. What is a stop page jumping to top when sticky topbar menu icon is clicked? How do you make a stop page jumping to top when sticky topbar menu icon is clicked? This script and codes were developed by Wing-Hou Chan on 06 December 2022, Tuesday.

Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked Previews

Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel='stylesheet prefetch' href='https://cdn.foundation5.zurb.com/foundation.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="row"> <h3>You're here probably because your page jumps to the top when you click on the hamburger icon in your topbar that is wrapped around a div with a sticky class.</h3> <h6>Or you have no idea what I am talking about and are just browsing. If this is you, I recommend you check out the world's most advanced front-end responsive framework, <a href="https://foundation.zurb.com/" targe="_blank">Foundation</a>, so you'll start to know what I am talking about.</h6> <h4>If you want more context on the issue see this post in Foundation Forum: <a href="https://foundation.zurb.com/forum/posts/881-page-jumps-to-top-on-top-bar-hamburger-icon-click" targe="_blank">https://foundation.zurb.com/forum/posts/881-page-jumps-to-top-on-top-bar-hamburger-icon-click</a>. Or check out his issue posted on GitHub: <a href="https://github.com/zurb/foundation/issues/4307">https://github.com/zurb/foundation/issues/4307</a></h4> <h3>Well here's your lucky day. This Pen will demo a solution to this issue.</h3> <h3>So let's get started...</h3> <h4>Below is the topbar. Take your browser window to below 640px, scroll down and click the hamburger icon to see the solution working.</h4>
</div>
<div class="sticky contain-to-grid"> <nav class="top-bar" data-topbar data-options="scrolltop:false;"> <ul class="title-area"> <li class="name"> <h1> <a href="#"> My Site </a> </h1> </li> <li class="toggle-topbar menu-icon"> <a href="#"> Menu </a> </li> </ul> <section class="top-bar-section"> <ul class="right"> <li class="active"> <a href="#"> Right Button Active </a> </li> <li class="has-dropdown"> <a href="#"> Right Button Dropdown </a> <ul class="dropdown"> <li> <a href="#"> First link in dropdown </a> </li> </ul> </li> </ul> <ul class="left"> <li> <a href="#"> Left Nav Button </a> </li> </ul> </section> </nav>
</div>
<div class="row"> <h3>And here's what you have to do:</h3> <h6>Add <code>data-options="scrolltop:false;"</code></h6> <pre> <code class="language-html"> <div class="code-container"> <span class="tag">&lt;<span class="title">nav</span> <span class="attribute">class</span>=<span class="value">"top-bar"</span> <span class="attribute">data-topbar</span> <span class="attribute">data-options</span>=<span class="value">"scrolltop:false;"</span>&gt;</span> </div> </code> </pre> <h3>That's it!</h3><small>No way!!! Why did I even bother looking at this.</small>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdn.foundation5.zurb.com/foundation.js'></script> <script src="js/index.js"></script>
</body>
</html>

Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked - Script Codes CSS Codes

.row h3, .row h4, .row h6
{ margin: 15px 0; font-family: 'Open Sans', sans-serif;
}
code
{ font-family: Consolas,'Liberation Mono',Courier,monospace; font-weight: bold; color: #BD240D;
}
pre code
{ display: block; padding: 0.5em; background: none repeat scroll 0% 0% #FAFAFA; color: #333;
}
pre .tag, pre .tag .title
{ color: #000080; font-weight: normal;
}
pre .attribute
{ color: #008080;
}
pre .tag .value
{ color: #D14;
}

Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked - Script Codes JS Codes

$(document).foundation();
Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked - Script Codes
Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked - Script Codes
Home Page Home
Developer Wing-Hou Chan
Username winghouchan
Uploaded December 06, 2022
Rating 3
Size 2,936 Kb
Views 8,096
Do you need developer help for Stop Page Jumping To Top When Sticky Topbar Menu Icon Is Clicked?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Wing-Hou Chan (winghouchan) Script Codes
Create amazing marketing copy with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!