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);
});
![Tabs - Script Codes](http://shots.codepen.io/takaneichinose/pen/JKRvpe-512.jpg)
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 |
Cat | 2,359 Kb |
Navbar login | 2,402 Kb |
Responsive Full-page Parallax Slider | 2,887 Kb |
Halloween Cute Spider | 2,229 Kb |
Pure CSS Full-page navigation | 2,532 Kb |
CRUD Table with JSON | 3,486 Kb |
Mario | 3,902 Kb |
Pure CSS Off-Canvas with Bootstrap | 2,517 Kb |
Tabs | 2,974 Kb |
Parallax scrolling | 8,951 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 |
CSS Tooltips | Darylldoyle | 2,599 Kb |
Wikipedia Viewer | Odylic | 2,333 Kb |
Hovers with popups | Zacharyolson | 2,380 Kb |
Sinclair Research Computers | MattCowley | 3,068 Kb |
Midterm dry run | Jds317 | 1,649 Kb |
Octopus Bar iPad App Interactions | Davidkpiano | 6,735 Kb |
Button Option Group | Honchoman | 1,859 Kb |
Gradients | Karpovsystems | 2,394 Kb |
Siema - add pagination to prototype | Pawelgrzybek | 2,575 Kb |
Guage | Roygwells | 5,653 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!