Transformer Tabs

Developer
Size
5,160 Kb
Views
28,336

How do I make an transformer tabs?

RWD n stuff!One set of semantic HTML. One set of JS.Tabs that turn into a small-screen-capable tap-to-reveal fully-functional system. . What is a transformer tabs? How do you make a transformer tabs? This script and codes were developed by Chris Coyier on 03 December 2022, Saturday.

Transformer Tabs Previews

Transformer Tabs - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Transformer Tabs</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ @charset "UTF-8";
.transformer-tabs ul { list-style: none; padding: 0; margin: 0; border-bottom: 3px solid white;
}
.transformer-tabs li { display: inline-block; padding: 0; vertical-align: bottom;
}
.transformer-tabs li:nth-child(1) .active { color: #c6a0d5; border-bottom-color: #9b59b6;
}
.transformer-tabs li:nth-child(2) .active { color: #8bc4ea; border-bottom-color: #3498db;
}
.transformer-tabs li:nth-child(3) .active { color: #f0b37e; border-bottom-color: #e67e22;
}
.transformer-tabs li:nth-child(4) .active { color: #df7c72; border-bottom-color: #c0392b;
}
.transformer-tabs a { display: inline-block; color: white; text-decoration: none; padding: 0.5rem;
}
.transformer-tabs a.active { border-bottom: 3px solid transparent; position: relative; bottom: -3px;
}
@media (max-width: 700px) { .transformer-tabs ul { border-bottom: 0; overflow: hidden; position: relative; background: #666; /* fallback */ background: linear-gradient(#666, #222); } .transformer-tabs ul::after { content: "☰"; position: absolute; top: 8px; right: 15px; z-index: 2; pointer-events: none; } .transformer-tabs ul.open a { position: relative; display: block; } .transformer-tabs li { display: block; } .transformer-tabs a { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .transformer-tabs a.active { border: 0; z-index: 1; background: #666; /* fallback */ background: linear-gradient(#666, #222); }
}
.tabs > div { display: none; padding: 1rem;
}
.tabs > div:nth-of-type(1) { background: #9b59b6;
}
.tabs > div:nth-of-type(2) { background: #3498db;
}
.tabs > div:nth-of-type(3) { background: #e67e22;
}
.tabs > div:nth-of-type(4) { background: #c0392b;
}
.tabs > .active { display: block;
}
body { padding: 1rem; background: #333; color: white; font: 100%/1.4 Sans-Serif;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div class="tabs"> <nav role='navigation' class="transformer-tabs"> <ul> <li><a href="#tab-1">Important Tab</a></li> <li><a href="#tab-2" class="active">Smurfvision</a></li> <li><a href="#tab-3">Monster Truck Rally</a></li> <li><a href="https://google.com">Go To Google &rarr;</a></li> </ul> </nav> <div id="tab-1"> <h2>Tab 1</h2> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad cum non iure magnam dolores earum nemo quo tempora ab unde! Nesciunt ea iste impedit suscipit cupiditate quam earum explicabo quas veniam doloribus sed aut aliquam repellendus deleniti laudantium molestias fuga nihil quidem voluptatum atque sapiente perferendis facilis. Tempora mollitia odio? </div> <div id="tab-2" class="active"> <h2>Tab 2</h2> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur est natus esse minima nihil quidem tenetur alias pariatur. Obcaecati repudiandae temporibus provident sapiente iure doloribus praesentium voluptates dolores quia eos velit fugit cum ipsam. Deleniti fugiat maxime vel tempore illum esse illo fugit quam recusandae aut aperiam omnis at quaerat! </div> <div id="tab-3"> <h2>Tab 3</h2> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Maiores numquam cupiditate aliquam quisquam repellendus fugit eaque asperiores voluptatem ut accusamus soluta corporis in facere quae provident itaque magni eum repellat ducimus dolore. Beatae aperiam accusamus at voluptatem ad sunt mollitia perspiciatis tempora numquam rerum aliquam deserunt illum necessitatibus nisi omnis. </div> <div id="tab-4"> <h2>Tab 4</h2> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Iste officiis impedit ut culpa quaerat error pariatur voluptatum sapiente alias quasi itaque voluptas expedita necessitatibus odio dolorem totam veniam quisquam nulla vero placeat corporis cupiditate assumenda amet inventore mollitia quidem similique laudantium maxime aperiam ea reprehenderit iusto a ad tempora harum. </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Transformer Tabs - Script Codes CSS Codes

@charset "UTF-8";
.transformer-tabs ul { list-style: none; padding: 0; margin: 0; border-bottom: 3px solid white;
}
.transformer-tabs li { display: inline-block; padding: 0; vertical-align: bottom;
}
.transformer-tabs li:nth-child(1) .active { color: #c6a0d5; border-bottom-color: #9b59b6;
}
.transformer-tabs li:nth-child(2) .active { color: #8bc4ea; border-bottom-color: #3498db;
}
.transformer-tabs li:nth-child(3) .active { color: #f0b37e; border-bottom-color: #e67e22;
}
.transformer-tabs li:nth-child(4) .active { color: #df7c72; border-bottom-color: #c0392b;
}
.transformer-tabs a { display: inline-block; color: white; text-decoration: none; padding: 0.5rem;
}
.transformer-tabs a.active { border-bottom: 3px solid transparent; position: relative; bottom: -3px;
}
@media (max-width: 700px) { .transformer-tabs ul { border-bottom: 0; overflow: hidden; position: relative; background: #666; /* fallback */ background: linear-gradient(#666, #222); } .transformer-tabs ul::after { content: "☰"; position: absolute; top: 8px; right: 15px; z-index: 2; pointer-events: none; } .transformer-tabs ul.open a { position: relative; display: block; } .transformer-tabs li { display: block; } .transformer-tabs a { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } .transformer-tabs a.active { border: 0; z-index: 1; background: #666; /* fallback */ background: linear-gradient(#666, #222); }
}
.tabs > div { display: none; padding: 1rem;
}
.tabs > div:nth-of-type(1) { background: #9b59b6;
}
.tabs > div:nth-of-type(2) { background: #3498db;
}
.tabs > div:nth-of-type(3) { background: #e67e22;
}
.tabs > div:nth-of-type(4) { background: #c0392b;
}
.tabs > .active { display: block;
}
body { padding: 1rem; background: #333; color: white; font: 100%/1.4 Sans-Serif;
}

Transformer Tabs - Script Codes JS Codes

var Tabs = { init: function() { this.bindUIfunctions(); this.pageLoadCorrectTab(); }, bindUIfunctions: function() { // Delegation $(document) .on("click", ".transformer-tabs a[href^='#']:not('.active')", function(event) { Tabs.changeTab(this.hash); event.preventDefault(); }) .on("click", ".transformer-tabs a.active", function(event) { Tabs.toggleMobileMenu(event, this); event.preventDefault(); }); }, changeTab: function(hash) { var anchor = $("[href=" + hash + "]"); var div = $(hash); // activate correct anchor (visually) anchor.addClass("active").parent().siblings().find("a").removeClass("active"); // activate correct div (visually) div.addClass("active").siblings().removeClass("active"); // update URL, no history addition // You'd have this active in a real situation, but it causes issues in an <iframe> (like here on CodePen) in Firefox. So commenting out. // window.history.replaceState("", "", hash); // Close menu, in case mobile anchor.closest("ul").removeClass("open"); }, // If the page has a hash on load, go to that tab pageLoadCorrectTab: function() { this.changeTab(document.location.hash); }, toggleMobileMenu: function(event, el) { $(el).closest("ul").toggleClass("open"); }
}
Tabs.init();
Transformer Tabs - Script Codes
Transformer Tabs - Script Codes
Home Page Home
Developer Chris Coyier
Username chriscoyier
Uploaded December 03, 2022
Rating 4.5
Size 5,160 Kb
Views 28,336
Do you need developer help for Transformer Tabs?

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!

Chris Coyier (chriscoyier) Script Codes
Create amazing marketing copy with AI!

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!