One Page Navigation
How do I make an one page navigation?
Nothing much to see here. Just a smooth scrolling effect plus navigation trigger. Probably, many has already shared the same kind of stuff. Well I just want to share. :). What is a one page navigation? How do you make a one page navigation? This script and codes were developed by Larry Geams Parangan on 13 September 2022, Tuesday.
One Page Navigation - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>One Page Navigation</title> <script src="https://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script> <link rel="stylesheet" href="css/style.css">
</head>
<body> <nav> <ul> <li><a href="#main">one</a></li> <li><a href="#secondary">two</a></li> <li><a href="#third">one</a></li> <li><a href="#fourth">two</a></li> <li><a href="#fifth">one</a></li> </ul>
</nav>
<section id="main" class="blue full-height"></section>
<section id="secondary" class="red full-height"></section>
<section id="third" class="green full-height"></section>
<section id="fourth" class="pink full-height"></section>
<section id="fifth" class="black full-height"></section> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
One Page Navigation - Script Codes CSS Codes
body{ margin: 0px; padding: 0px;
}
nav{ -webkit-backface-visibility: hidden; z-index: 5; position: fixed; top: 10%; left: 0px; right: 0px; margin: auto; width: 100px;
}
nav li{ height: 20px; margin: 20px 0px; list-style: none;
}
nav a{ display: block; width: 25px; height: 25px; text-indent: -9999px; border-radius: 25px; -moz-border-radius:25px; -webkit-border-radius:25px; background-color: transparent; border: 3px solid #fff; transition: all 0.3s ease; position: relative; left: 0px; top: 0px;
}
nav a:hover, nav a.active{ background-color: #fff; width: 30px; height: 30px; left: -3px; top: -2px}
.red { background-color: #B23751; }
.blue { background-color: #346CA5; }
.green { background-color: #65B237; }
.pink { background-color: #c0392b; }
.black { background-color: #2c3e50; }
section{ height: 980px; }
One Page Navigation - Script Codes JS Codes
$('a[href^="#"]').click(function(event) { var id = $(this).attr("href"); var target = $(id).offset().top; $('html, body').animate({scrollTop:target}, 500); event.preventDefault(); });
function getTargetTop(elem){ var id = elem.attr("href"); var offset = 60; return $(id).offset().top - offset;
} $(window).scroll(function(e){ isSelected($(window).scrollTop()) });
var sections = $('a[href^="#"]');
function isSelected(scrolledTo){ var threshold = 100; var i; for (i = 0; i < sections.length; i++) { var section = $(sections[i]); var target = getTargetTop(section); if (scrolledTo > target - threshold && scrolledTo < target + threshold) { sections.removeClass("active"); section.addClass("active"); } };
}
Developer | Larry Geams Parangan |
Username | larrygeams |
Uploaded | September 13, 2022 |
Rating | 4.5 |
Size | 2,534 Kb |
Views | 28,336 |
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!
Name | Size |
Browser Detection - Google Chrome | 2,866 Kb |
Slide Toggle Navigation | 2,590 Kb |
Simple E-Commerce | 2,919 Kb |
Pure CSS Checklist Icon | 2,121 Kb |
Solution for Long Drop Down Items | 3,127 Kb |
CSS3 Accordion | 2,661 Kb |
Pure CSS Login Form | 2,343 Kb |
Click and Hold Button Animation | 2,433 Kb |
Just Flat | 2,261 Kb |
The Android Story | 4,745 Kb |
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!
Name | Username | Size |
Calendar | Miroot | 2,033 Kb |
Nice textured background | Hans | 2,659 Kb |
Break Out | AzazelN28 | 12,431 Kb |
The Rope | Chribbe | 2,886 Kb |
Materializecss input form | Jasonchan | 1,443 Kb |
BenU Maintenance Site | Ksherman | 4,893 Kb |
Fading gradient button | Insprd | 1,713 Kb |
Adding Items | Valhead | 4,008 Kb |
Addthis_button | Esambino | 1,691 Kb |
Add This API | ThatGuySam | 2,848 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!