Tab Interface (PE)
How do I make an tab interface (pe)?
What is a tab interface (pe)? How do you make a tab interface (pe)? This script and codes were developed by Heydon on 04 February 2023, Saturday.
Tab Interface (PE) - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Tab Interface (PE)</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="tabbed"> <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> <li> <a href="#section4">Section 4</a> </li> </ul> <section id="section1"> <h2>Section 1</h2> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod, tortor nec pharetra ultricies, ante erat imperdiet velit, nec laoreet enim lacus a velit. <a href="#">Nam luctus</a>, enim in interdum condimentum, nisl diam iaculis lorem, vel volutpat mi leo sit amet lectus. Praesent non odio bibendum magna bibendum accumsan.</p> </section> <section id="section2"> <h2>Section 2</h2> <p>Nullam at diam nec arcu suscipit auctor non a erat. Sed et magna semper, eleifend magna non, facilisis nisl. Proin et est et lorem dictum finibus ut nec turpis. Aenean nisi tortor, euismod a mauris a, mattis scelerisque tortor. Sed dolor risus, varius a nibh id, condimentum lacinia est. In lacinia cursus odio a aliquam. Curabitur tortor magna, laoreet ut rhoncus at, sodales consequat tellus.</p> </section> <section id="section3"> <h2>Section 3</h2> <p>Phasellus ac tristique orci. Nulla maximus <a href="">justo nec dignissim consequat</a>. Sed vehicula diam sit amet mi efficitur vehicula in in nisl. Aliquam erat volutpat. Suspendisse lorem turpis, accumsan consequat consectetur gravida, <a href="#">pellentesque ac ante</a>. Aliquam in commodo ligula, sit amet mollis neque. Vestibulum at facilisis massa.</p> </section> <section id="section4"> <h2>Section 4</h2> <p>Nam luctus, enim in interdum condimentum, nisl diam iaculis lorem, vel volutpat mi leo sit amet lectus. Praesent non odio bibendum magna bibendum accumsan. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam euismod, tortor nec pharetra ultricies, ante erat imperdiet velit, nec laoreet enim lacus a velit. </p> </section>
</div> <script src="js/index.js"></script>
</body>
</html>
Tab Interface (PE) - Script Codes CSS Codes
body { max-width: 40rem; padding: 0 1rem; font-size: 125%; line-height: 1.5; margin: 1.5rem auto; font-family: Arial, sans-serif;
}
* { color: inherit; margin: 0;
}
[role="tablist"] { padding: 0;
}
[role="tablist"] li, [role="tablist"] a { display: inline-block;
}
[role="tablist"] a { text-decoration: none; padding: 0.5rem 1em;
}
[role="tablist"] [aria-selected] { border: 2px solid; background: #fff; border-bottom: 0; position: relative; top: 2px;
}
[role="tabpanel"] { border: 2px solid; padding: 1.5rem;
}
[role="tabpanel"] * + * { margin-top: 0.75rem;
}
*:focus { outline: none; box-shadow: inset 0 0 0 4px lightBlue;
}
@media (max-width: 550px) { [role="tablist"] li, [role="tablist"] a { display: block; position: static; } [role="tablist"] a { border: 2px solid #222 !important; } [role="tablist"] li + li a { border-top: 0 !important; } [role="tablist"] [aria-selected] { position: static; } [role="tablist"] [aria-selected]::after { content: '\0020⬅'; } [role="tabpanel"] { border-top: 0; }
}
Tab Interface (PE) - Script Codes JS Codes
'use strict';
(function () { // Get relevant elements and collections var tabbed = document.querySelector('.tabbed'); var tablist = tabbed.querySelector('ul'); var tabs = tablist.querySelectorAll('a'); var panels = tabbed.querySelectorAll('[id^="section"]'); // The tab switching function var switchTab = function switchTab(oldTab, newTab) { newTab.focus(); // Make the active tab focusable by the user (Tab key) newTab.removeAttribute('tabindex'); // Set the selected state newTab.setAttribute('aria-selected', 'true'); oldTab.removeAttribute('aria-selected'); oldTab.setAttribute('tabindex', '-1'); // Get the indices of the new and old tabs to find the correct // tab panels to show and hide var index = Array.prototype.indexOf.call(tabs, newTab); var oldIndex = Array.prototype.indexOf.call(tabs, oldTab); panels[oldIndex].hidden = true; panels[index].hidden = false; }; // Add the tablist role to the first <ul> in the .tabbed container tablist.setAttribute('role', 'tablist'); // Add semantics are remove user focusability for each tab Array.prototype.forEach.call(tabs, function (tab, i) { tab.setAttribute('role', 'tab'); tab.setAttribute('id', 'tab' + (i + 1)); tab.setAttribute('tabindex', '-1'); tab.parentNode.setAttribute('role', 'presentation'); // Handle clicking of tabs for mouse users tab.addEventListener('click', function (e) { e.preventDefault(); var currentTab = tablist.querySelector('[aria-selected]'); if (e.currentTarget !== currentTab) { switchTab(currentTab, e.currentTarget); } }); // Handle keydown events for keyboard users tab.addEventListener('keydown', function (e) { // Get the index of the current tab in the tabs node list var index = Array.prototype.indexOf.call(tabs, e.currentTarget); // Work out which key the user is pressing and // Calculate the new tab's index where appropriate var dir = e.which === 37 ? index - 1 : e.which === 39 ? index + 1 : e.which === 40 ? 'down' : null; if (dir !== null) { e.preventDefault(); // If the down key is pressed, move focus to the open panel, // otherwise switch to the adjacent tab dir === 'down' ? panels[i].focus() : tabs[dir] ? switchTab(e.currentTarget, tabs[dir]) : void 0; } }); }); // Add tab panel semantics and hide them all Array.prototype.forEach.call(panels, function (panel, i) { panel.setAttribute('role', 'tabpanel'); panel.setAttribute('tabindex', '-1'); var id = panel.getAttribute('id'); panel.setAttribute('aria-labelledby', tabs[i].id); panel.hidden = true; }); // Initially activate the first tab and reveal the first tab panel tabs[0].removeAttribute('tabindex'); tabs[0].setAttribute('aria-selected', 'true'); panels[0].hidden = false;
})();
Developer | Heydon |
Username | heydon |
Uploaded | February 04, 2023 |
Rating | 3.5 |
Size | 4,721 Kb |
Views | 0 |
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 |
Redesigned gender form field | 1,160 Kb |
Bookish | 2,094 Kb |
Current Page Test Case | 1,827 Kb |
Just add javascript | 2,010 Kb |
Content Aware Navigation | 1,950 Kb |
Hash change logging | 2,134 Kb |
Theme color inverter with filter | 0 Kb |
Accessible, pretty radio controls | 2,112 Kb |
FUN TIMES Competition | 3,473 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 |
V.35 The Monolith Update - Hero Release Notes | Jordan | 12,045 Kb |
Improved Page Flipping Effect | Usaphp | 5,201 Kb |
Part 19 Bootstrap split button dropdown | Venkatesha | 1,601 Kb |
ECharts Version 3.0 - Bar Marker Chart | WebCodePro | 2,726 Kb |
TestTube CSS | EZPK | 2,710 Kb |
Simple CSS loader. | Cabrera | 2,574 Kb |
CSS3 Selectables with information rollover | Jasonmayes | 9,565 Kb |
Jquery 2d character movement | Drewtadams | 4,291 Kb |
Colorful Sliders | Chanrith | 1,246 Kb |
A Pen by Adrien Clerbois | AClerbois | 6,501 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!