web299.com
全部
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
首页
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
当前位置:
首页
>
网页特效
>
选项卡
Material Design风格实用Tabs选项卡
分类:
选项卡
日期:
2024-05-14
点击(1)
评论(0)
演 示
免费下载
简介
##### HTML结构 该Tabs选项卡的HTML结构如下:ul无序列表是选项卡的Tab,nav元素是选项卡的左右箭头导航按钮。div.nav-content是选项卡的内容,它通过tab-id属性和Tabs关联。 ```html
Tab 1
Tab 2
Tab 3
Tab 4
Tab 5
``` ```html
``` ```html
......
``` ##### CSS样式 该Tabs选项卡的按钮点击波特效的CSS样式如下: ```html [ripple] { z-index: 1; position: relative; overflow: hidden; } [ripple] .ripple { position: absolute; background: #FFFFFF; width: 12px; height: 12px; border-radius: 100%; -webkit-animation: ripple 1.6s; animation: ripple 1.6s; } @-webkit-keyframes ripple { 0% { -webkit-transform: scale(1); transform: scale(1); opacity: 0.2; } 100% { -webkit-transform: scale(40); transform: scale(40); opacity: 0; } } @keyframes ripple { 0% { -webkit-transform: scale(1); transform: scale(1); opacity: 0.2; } 100% { -webkit-transform: scale(40); transform: scale(40); opacity: 0; } } ``` ##### JavaScript 该Tabs选项卡使用下面的jQuery代码来完成选项卡的切换和按钮点击波特效的生成。 ```html $(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 = $('
'), 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); }); }); ```
相关推荐
html5浪漫粒子表白文字特效
SlidesJS幻灯片特效
html5瀑布流相册特效
css3 svg实现的情人节表白鲜花动画特效
t-scroll.js基于ES6的DOM元素,过渡动画库插件
纯js写省市区三级联动效果
广告
广告