Material Tabs

Developer
Size
3,215 Kb
Views
32,384

How do I make an material tabs?

What is a material tabs? How do you make a material tabs? This script and codes were developed by Albert Miller on 23 August 2022, Tuesday.

Material Tabs Previews

Material Tabs - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Material Tabs</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="tab">	<div class="tab__header"><span class="tab__title">Address</span></div><!--	--><div class="tab__header"><span class="tab__title">Contacts</span></div><!--	--><div class="tab__header"><span class="tab__title">Notes</span></div>	<div class="tab__underline"></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>

Material Tabs - Script Codes CSS Codes

@import url(https://fonts.googleapis.com/css?family=Roboto:400);
.tab { box-shadow: 0 2px 5px rgba(0, 0, 0, 0.26); background-color: #fffff; display: inline-block; position: relative;
}
.tab__header { box-sizing: border-box; cursor: pointer; display: inline-block; padding: 1em 0; text-align: center; transition: border-bottom .4s; width: 10em;
}
.tab__title, .tab__title--active { color: rgba(0, 0, 0, 0.38); font-family: 'Roboto'; transition: color .4s;
}
.tab__title--active { color: #1976d2;
}
.tab__underline { background-color: #1976d2; bottom: 0; height: 5px; left: 0; position: absolute; right: 0; transform: translateX(0%) scaleX(0.33); transform-origin: left center; transition: transform .4s; width: 100%; z-index: 10000;
}

Material Tabs - Script Codes JS Codes

$(document).ready(function() {	$('.tab__header:first-child').find('.tab__title').attr('class', 'tab__title--active');
});
var previousIndex = 0;
$('.tab__header').on('click', function(){	var tabIndex = $(this).index('.tab__header');	var tabLength = $('.tab .tab__header').length;	var tabFinalIndex = tabLength - 1;	var translateString = 'translateX('	var scaleString = 'scaleX('	var translateMathStart;	if (previousIndex !== tabIndex) {	if (tabIndex > previousIndex) {	if (previousIndex === 0) {	translateMathStart = 0;	console.log('Translate Start: ' + translateMathStart);	} else {	translateMathStart = trimDecimal(previousIndex / tabLength);	console.log('Translate Start: ' + translateMathStart);	}	} else if (tabIndex < previousIndex) {	translateMathStart = trimDecimal(tabIndex / tabLength);	console.log('Translate Start: ' + translateMathStart);	} else if (tabIndex === 0) {	translateMathStart = trimDecimal(tabIndex / tabLength);	console.log('Translate Start: ' + translateMathStart);	}	var translateMathEnd = trimDecimal(tabIndex / tabLength);	console.log('Translate End: ' + translateMathEnd);	var scaleMathStart = (1 / tabLength) * (Math.abs((tabIndex - previousIndex)) + 1);	console.log('Scale Start:' + scaleMathStart);	var scaleMathEnd = 1 / tabLength;	console.log('Scale End:' + scaleMathEnd);	var styleStringStart = 'transform: ' + translateString + translateMathStart + '%) ' + scaleString + scaleMathStart + ')';	var styleStringEnd = 'transform: ' + translateString + translateMathEnd + '%) ' + scaleString + scaleMathEnd + ')';	//$('.tab__underline').attr('style', styleStringStart);	$('.tab__underline').attr('style', styleStringEnd);	window.setTimeout(function() {	//$('.tab__underline').attr('style', styleStringEnd);	}, 200);	$('.tab__title--active').attr('class', 'tab__title');	$(this).find('.tab__title').attr('class', 'tab__title--active');	previousIndex = tabIndex;	}
});
function trimDecimal(number) {	number = +number.toFixed(2);	if(number.toString().length > 2) {	number = number.toString().slice(2, 4);	}	if(number.toString().length === 1 && number.toString() !== "0") {	number = number.toString().concat("0");	}	return number;
}
Material Tabs - Script Codes
Material Tabs - Script Codes
Home Page Home
Developer Albert Miller
Username SinceSidSlid
Uploaded August 23, 2022
Rating 3
Size 3,215 Kb
Views 32,384
Do you need developer help for Material 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!

Albert Miller (SinceSidSlid) Script Codes
Create amazing captions 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!