Focus management of smooth scrolling
How do I make an focus management of smooth scrolling?
What is a focus management of smooth scrolling? How do you make a focus management of smooth scrolling? This script and codes were developed by Heydon on 27 August 2022, Saturday.
Focus management of smooth scrolling - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Focus management of smooth scrolling</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <nav role="navigation"> <ul> <li><a href="#section1">Section 1</a></li> <li><a href="#section2">Section 2</a></li> <li><a href="#section3">Section 3</a></li> </ul>
</nav>
<section id="section1"> <h2>Section 1</h2> <p>Donec tempus tempus tellus, ac lacinia turpis mattis ac. Nulla vel magna sit amet dui lobortis commodo vitae vel nulla sit amet ante hendrerit tempus. Sed dapibus, lectus sit amet adipiscing egestas, mauris est viverra nibh. Donec tempus tempus tellus, ac lacinia turpis mattis ac. Nulla vel magna sit amet dui lobortis commodo vitae vel nulla sit amet ante hendrerit tempus. Sed dapibus, lectus sit amet adipiscing egestas, mauris est viverra nibh. Donec tempus tempus tellus, ac lacinia turpis mattis ac. Nulla vel magna sit amet dui lobortis commodo vitae vel nulla sit amet ante hendrerit tempus. Sed dapibus, lectus sit amet adipiscing egestas, mauris est viverra nibh.</p>
</section>
<section id="section2"> <h2>Section 2</h2> <p>Maecenas sit amet tellus – nec mi gravida posuere non <a href="#">pretium magna</a>. Potenti et eros sed justo commodo bibendum non at nunc. Suspendisse potenti cras molestie, risus a enim convallis vitae luctus libero lacinia. Donec tempus tempus tellus, ac lacinia turpis mattis ac. Nulla vel magna sit amet dui lobortis commodo vitae vel nulla sit amet ante hendrerit tempus. Sed dapibus, lectus sit amet adipiscing egestas, mauris est viverra nibh. Donec tempus tempus tellus, ac lacinia turpis mattis ac. Nulla vel magna sit amet dui lobortis commodo vitae vel nulla sit amet ante hendrerit tempus. Sed dapibus, lectus sit amet adipiscing egestas, mauris est viverra nibh. Donec tempus tempus tellus, ac lacinia turpis mattis ac. Nulla vel magna sit amet dui lobortis commodo vitae vel nulla sit amet ante hendrerit tempus. Sed dapibus, lectus sit amet adipiscing egestas, mauris est viverra nibh.</p>
</section>
<section id="section3"> <h2>Section 3</h2> <p>Donec a congue leo. Suspendisse potenti cras molestie, risus a enim convallis vitae luctus libero lacinia. Nunc iaculis risus vel orci ornare dignissim sed vitae nulla.</p>
</section> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Focus management of smooth scrolling - Script Codes CSS Codes
body { max-width: 30em; padding: 1.5em 0; margin: 0 auto; font-size: 150%;
}
nav li { display: inline; padding-right: 1em;
}
ul { margin: 0; padding: 0;
}
a { color: blue;
}
Focus management of smooth scrolling - Script Codes JS Codes
/* Basics lifted from a CSS Tricks demo (http://css-tricks.com/snippets/jquery/smooth-scrolling/), with focus() and URL hash updating added where commented */
$(function() { /* ADDED: make sections focusable */ $('section[id]').attr('tabindex', '-1'); /* end ADDED */ $('a[href*=#]:not([href=#])').on('click', function(e) { var $linkElem = $(this); if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { e.preventDefault(); var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 1000, function() { target.focus(); window.location.hash = $linkElem.attr('href').substring(1); }); } } });
});
Developer | Heydon |
Username | heydon |
Uploaded | August 27, 2022 |
Rating | 3 |
Size | 2,506 Kb |
Views | 40,480 |
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 |
Theme color inverter with filter | 0 Kb |
Just add javascript | 2,010 Kb |
Ransom Note With Google Font Subsets | 2,217 Kb |
Invert custom properties | 2,026 Kb |
Redesigned gender form field | 1,160 Kb |
CSS only, automated, and accessible external link icon | 1,678 Kb |
Vue.js TODO List | 4,218 Kb |
Animated focus styles for kbd users | 1,987 Kb |
DIV wormhole | 1,932 Kb |
Controlled chaos | 1,562 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 |
Image Stack Test SCSS | CalvinMorett | 2,799 Kb |
Particle Motion trajectories | Sniejadlik | 5,899 Kb |
Kudos Please | TimPietrusky | 6,624 Kb |
Wip elementary os navbar | Nickcolley | 2,993 Kb |
Static Image to Video Block | Grayghostvisuals | 4,864 Kb |
SVG hamburger menu button | Elifitch | 2,602 Kb |
JQuery exercise | Brian-baum | 3,780 Kb |
Sass Radar | Jlong | 6,887 Kb |
A Pen by Jess | Jessamyne | 5,100 Kb |
Ocean | Gordonnl | 2,817 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!