Tabs
How do I make an tabs?
Tabs layout inspired by (based on) Google's Material Design.Font used: https://www.google.com/fonts#UsePlace:use/Collection:Droid+Sans. What is a tabs? How do you make a tabs? This script and codes were developed by Takane Ichinose on 10 November 2022, Thursday.
Tabs - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Tabs</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Droid+Sans'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div style="width: 600px; margin: 40px auto 0;"> <div class="tab"> <ul class="links"> <li class="active"> <a href="#item1">ITEM 1</a> </li> <li> <a href="#item2">ITEM TWO</a> </li> <li> <a href="#item3">ITEM THREE</a> </li> <div class="tab-ptr"></div> <div class="tab-page"></div> </ul> <div class="container"> <div class="contents"> <div class="content"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. </div> <div class="content"> Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. </div> <div class="content"> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> </div> </div> </div>
</div> <script src="js/index.js"></script>
</body>
</html>
Tabs - Script Codes CSS Codes
* { font-family: "Droid Sans", sans-serif; padding: 0; margin: 0;
}
.tab { margin: 0 auto;
}
.tab > ul.links { list-style-type: none; background: #1d94f5; overflow: hidden; position: relative; white-space: nowrap;
}
.tab > ul.links > li { display: inline-block;
}
.tab > ul.links > li > a { text-decoration: none; font-size: 16px; font-weight: bold; color: #005499; padding: 15px 20px; display: block; transition: color 0.6s ease;
}
.tab > ul.links > li.active > a { color: white;
}
.tab > ul.links > .tab-ptr { background: #f2f2f2; height: 3px; position: absolute; bottom: 0; transition: left 0.6s ease, width 0.6s ease;
}
.tab > ul.links > .tab-ptr:after { content: ""; border: solid 4px #f2f2f2; border-top: none; border-left-color: transparent; border-right-color: transparent; display: block; position: absolute; top: -4px; left: calc(50% - 4px);
}
.tab > .container { background: #f2f2f2; overflow: hidden; position: relative;
}
.tab > .container > .contents { white-space: nowrap; position: relative; transition: left 0.6s ease, height 0.6s ease;
}
.tab > .container > .contents > .content { padding: 20px; display: inline-block; vertical-align: top; white-space: normal; word-break: break-all;
}
Tabs - Script Codes JS Codes
var tabLinks = document.querySelectorAll(".tab > ul.links > li");
var tabContent = document.querySelector(".tab > .container > .contents");
var tabContents = document.querySelectorAll(".tab > .container > .contents > .content");
var activeTabPointer = document.querySelector(".tab-ptr");
var activeNum = 0;
function numToPx(value) { return value.toString() + "px";
}
activeTabPointer.style.left = numToPx(tabLinks[0].offsetLeft);
activeTabPointer.style.width = numToPx(tabLinks[0].clientWidth);
tabContent.style.height = numToPx(tabContents[0].clientHeight);
for (var i = 0; i < tabLinks.length; i++) { tabLinks[i].addEventListener("click", function(evt) { activeTabPointer.style.left = numToPx(this.offsetLeft); activeTabPointer.style.width = numToPx(this.clientWidth); for (var j = 0; j < tabLinks.length; j++) { tabLinks[j].classList.remove("active"); tabContents[j].classList.remove("active"); if (this === tabLinks[j]) { tabContent.style.left = numToPx(0 - tabContents[j].offsetLeft); tabContent.style.height = numToPx(tabContents[j].clientHeight); activeNum = j; } } this.classList.add("active"); });
}
window.addEventListener("resize", function() { tabContent.style.left = numToPx(0 - tabContents[activeNum].offsetLeft); tabContent.style.height = numToPx(tabContents[activeNum].clientHeight);
});
Developer | Takane Ichinose |
Username | takaneichinose |
Uploaded | November 10, 2022 |
Rating | 3 |
Size | 2,974 Kb |
Views | 12,144 |
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 |
Cow drawing | 5,437 Kb |
Navbar login | 2,402 Kb |
CRUD Table with JSON | 3,486 Kb |
Cat | 2,359 Kb |
Parallax Scrolling | 2,665 Kb |
Spinning star | 1,895 Kb |
Hangman game | 3,340 Kb |
Level 1 monster | 3,123 Kb |
Responsive alert box | 3,227 Kb |
Flickering Fluorescent Lamp | 2,157 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 |
Resume | Rottingroom | 5,483 Kb |
We Simplify animation | Meodai | 48,169 Kb |
React Recipe Box | Krokodill | 5,347 Kb |
Falling Down the Rabbit Hole | Rachelnabors | 4,578 Kb |
Slide like Mailbox | Hmps | 3,758 Kb |
Scroll to view if element partially out of view port height | ChrisMaki | 2,104 Kb |
Video Player Custom Controls | EleftheriaBatsou | 3,665 Kb |
Bootstrap example | Ssaakkaa | 2,716 Kb |
A Pen by Matt Popovich | Mpopv | 3,349 Kb |
Another brick in the wall | Fivera | 1,955 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!