jQuery扁平化Tabs選項卡特效



74 293 98



特效描述:jQuery扁平化 Tabs選項卡特效,jQuery扁平化Tabs選項卡特效

代碼結構

1. 引入CSS

<link rel='stylesheet prefetch' href='css/reset.css'>
<link rel="stylesheet" type="text/css" href="css/default.css">
<link rel='stylesheet prefetch' href='https://fonts.useso.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons'>
<link rel="stylesheet" type="text/css" href="css/styles.css">

2. 引入JS

<script src='js/stopExecutionOnTimeout.js?t=1'></script>
<script src="http://libs.useso.com/js/jquery/2.1.1/jquery.min.js" type="text/javascript"></script>
<script>window.jQuery || document.write('<script src="js/jquery-2.1.1.min.js"><\/script>')</script>

3. HTML代碼

<article class="htmleaf-container">
	<div class="tabs">
	  <div class="tabs-header">
		<div class="border"></div>
		<ul>
		  <li class="active"><a href="#tab-1" tab-id="1" ripple="ripple" ripple-color="#FFF">Tab 1</a></li>
		  <li><a href="#tab-2" tab-id="2" ripple="ripple" ripple-color="#FFF">Tab 2</a></li>
		  <li><a href="#tab-3" tab-id="3" ripple="ripple" ripple-color="#FFF">Tab 3</a></li>
		  <li><a href="#tab-4" tab-id="4" ripple="ripple" ripple-color="#FFF">Tab 4</a></li>
		  <li><a href="#tab-5" tab-id="5" ripple="ripple" ripple-color="#FFF">Tab 5</a></li>
		</ul>
		<nav class="tabs-nav"><i id="prev" ripple="ripple" ripple-color="#FFF" class="material-icons">&#xE314;</i><i id="next" ripple="ripple" ripple-color="#FFF" class="material-icons">&#xE315;</i></nav>
	  </div>
	  <div class="tabs-content">
		<div tab-id="1" class="tab active">1. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Ellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor.</div>
		<div tab-id="2" class="tab">2. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam.</div>
		<div tab-id="3" class="tab">3. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor.</div>
		<div tab-id="4" class="tab">4. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor. Maecenas faucibus mollis interdum. Donec ullamcorper nulla non metus auctor fringilla. Aenean lacinia bibendum nulla sed consectetur. Aenean lacinia bibendum nulla sed consectetur.</div>
		<div tab-id="5" class="tab">5. Donec ullamcorper nulla non metus auctor fringilla. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Curabitur blandit tempus porttitor.Cras mattis consectetur purus sit amet fermentum. Maecenas sed diam eget risus varius blandit sit amet non magna. Nullam quis risus eget urna mollis ornare vel eu leo. Morbi leo risus, porta ac consectetur ac, vestibulum at eros. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Maecenas sed diam eget risus varius blandit sit amet non magna. Maecenas sed diam eget risus varius blandit sit amet non magna. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Integer posuere erat a ante venenatis dapibus posuere velit aliquet. Vestibulum id ligula porta felis euismod semper. Aenean lacinia bibendum nulla sed consectetur. Donec id elit non mi porta gravida at eget metus. Donec id elit non mi porta gravida at eget metus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Maecenas faucibus mollis interdum. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Aenean lacinia bibendum nulla sed consectetur. Maecenas faucibus mollis interdum. Donec ullamcorper nulla non metus auctor fringilla. Aenean lacinia bibendum nulla sed consectetur. Aenean lacinia bibendum nulla sed consectetur.</div>
	  </div>
	</div>
</article>
<script>
$(document).ready(function () {
	var activePos = $('.tabs-header .active').position();
	function changePos() {
		activePos = $('.tabs-header .active').position();
		$('.border').stop().css({
			left: activePos.left,
			width: $('.tabs-header .active').width()
		});
	}
	changePos();
	var tabHeight = $('.tab.active').height();
	function animateTabHeight() {
		tabHeight = $('.tab.active').height();
		$('.tabs-content').stop().css({ height: tabHeight + 'px' });
	}
	animateTabHeight();
	function changeTab() {
		var getTabId = $('.tabs-header .active a').attr('tab-id');
		$('.tab').stop().fadeOut(300, function () {
			$(this).removeClass('active');
		}).hide();
		$('.tab[tab-id=' + getTabId + ']').stop().fadeIn(300, function () {
			$(this).addClass('active');
			animateTabHeight();
		});
	}
	$('.tabs-header a').on('click', function (e) {
		e.preventDefault();
		var tabId = $(this).attr('tab-id');
		$('.tabs-header a').stop().parent().removeClass('active');
		$(this).stop().parent().addClass('active');
		changePos();
		tabCurrentItem = tabItems.filter('.active');
		$('.tab').stop().fadeOut(300, function () {
			$(this).removeClass('active');
		}).hide();
		$('.tab[tab-id="' + tabId + '"]').stop().fadeIn(300, function () {
			$(this).addClass('active');
			animateTabHeight();
		});
	});
	var tabItems = $('.tabs-header ul li');
	var tabCurrentItem = tabItems.filter('.active');
	$('#next').on('click', function (e) {
		e.preventDefault();
		var nextItem = tabCurrentItem.next();
		tabCurrentItem.removeClass('active');
		if (nextItem.length) {
			tabCurrentItem = nextItem.addClass('active');
		} else {
			tabCurrentItem = tabItems.first().addClass('active');
		}
		changePos();
		changeTab();
	});
	$('#prev').on('click', function (e) {
		e.preventDefault();
		var prevItem = tabCurrentItem.prev();
		tabCurrentItem.removeClass('active');
		if (prevItem.length) {
			tabCurrentItem = prevItem.addClass('active');
		} else {
			tabCurrentItem = tabItems.last().addClass('active');
		}
		changePos();
		changeTab();
	});
	$('[ripple]').on('click', function (e) {
		var rippleDiv = $('<div class="ripple" />'), rippleOffset = $(this).offset(), rippleY = e.pageY - rippleOffset.top, rippleX = e.pageX - rippleOffset.left, ripple = $('.ripple');
		rippleDiv.css({
			top: rippleY - ripple.height() / 2,
			left: rippleX - ripple.width() / 2,
			background: $(this).attr('ripple-color')
		}).appendTo($(this));
		window.setTimeout(function () {
			rippleDiv.remove();
		}, 1500);
	});
});
</script>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊
VICTORY
VICTORY :  很實用的效果 https://www.mybj123.com/
2019-09-19 16:32:37


熱門標簽: 文字疊加 文字層疊 文字收縮展開 文字收縮 文字展開 文字淡出淡進 文字淡出 文字淡進 文字翻轉 文字旋轉 文字放大縮小 文字縮放 文字大小 文字放大 文字縮小 文字變大 文字變小 文字提示框 提示文字 文字全屏 文字拖動 文字拖拽 滑動選項卡 滑動切換 滾動切換 滾動條切換 文字延遲加載 文字延遲 文字加載 h5文字動畫 h5文字邊框動畫 html5文字動畫 html5文字邊框動畫 360全景 360度全景 文字滑動 文字滑塊 文字滾動 文字無縫滾動 文字間歇滾動 文字切換 文字選項卡 選項卡切換 選項卡 切換 tab切換 頁面切換 選項卡插件 切換插件 滑動手風琴 圖片文字 文字導航菜單 文字導航 文字菜單 文字 文字插件 文字列表 選項卡自動切換
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

老夫子电子