jQuery扁平化Tabs选项卡特效



70 279 94



特效描述: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

加群请备注:从官网了解到