简单 jQuery响应式选项卡接口插件 jQueryTab

  • 源码大小:12.72KB
  • 所需积分:1积分
  • 源码编号:19JP-3644
  • 浏览次数:1108次
  • 最后更新:2023年07月06日
  • 所属栏目:布局
本站默认解压密码:19jp.com 或 19jp_com

简介

还有另一个jQuery选项卡插件,用于创建具有许多选项和CSS3转换动画支持的响应选项卡面板。

特征:

  • 在iPad、iPhone等小型设备中,自动将选项卡转换为手风琴式界面。。。
  • 使用cookie记住最后一个活动选项卡。
  • 键盘导航。
  • 支持浏览器历史记录API。
  • 单击或悬停时打开。
  • 4个选项卡转换:淡入淡出|翻转|放大|滑动左移。
  • 2个手风琴过渡:正常和滑动。

如何使用它:

1.在网页上包含jQuery javascript库。

  1. <script src="/path/to/cdn/jquery.slim.min.js"></script>

2.在页面上包含jQueryTab插件的CSS和JavaScript。

  1. <!-- Core Stylesheet -->
  2. <link rel="stylesheet" href="jQueryTab.css" />
  3. <!-- CSS3 Animations -->
  4. <link rel="stylesheet" href="animation.css" />
  5. <!-- Main JavaScript -->
  6. <script src="js/jQueryTab.js"></script>

3.按照如下所示的html结构创建选项卡和选项卡式内容:

  1. <div class="tabs-demo">
  2. <ul class="tabs">
  3. <li><a href="#tab1">Tab1</a></li>
  4. <li><a href="#tab2">Tab2</a></li>
  5. <li><a href="#tab3">Tab3</a></li>
  6. <li><a href="#tab4">Tab4</a></li>
  7. </ul>
  8. <section class="tab_content" id="tab1">
  9. <p> Tabbed Conternt 1</p>
  10. </section>
  11. <section class="tab_content" id="tab2">
  12. <p>Tabbed Conternt 2</p>
  13. </section>
  14. <section class="tab_content" id="tab3">
  15. <p>Tabbed Conternt 3</p>
  16. </section>
  17. <section class="tab_content" id="tab4">
  18. <p>Tabbed Conternt 4</p>
  19. </section>
  20. </div>

4.初始化顶部容器上的插件并完成。

  1. $('.tabs-demo').jQueryTab({
  2. // options here
  3. });

5.自定义选项卡的所有可用选项。

  1. $('.tabs-demo').jQueryTab({
  2.  
  3. // class of the tabs
  4. tabClass:'tabs',
  5.  
  6. // class of the header of accordion on smaller screens
  7. accordionClass:'accordion_tabs',
  8.  
  9. // class of content wrapper
  10. contentWrapperClass:'tab_content_wrapper',
  11.  
  12. // class of container
  13. contentClass:'tab_content',
  14.  
  15. // name of the class used for active tab
  16. activeClass:'active',
  17.  
  18. // enable accordion on smaller screens
  19. responsive:true,
  20.  
  21. // the breakpoint
  22. responsiveBelow:600,
  23.  
  24. // allow all tabs to collapse on accordions
  25. collapsible:true,
  26.  
  27. // remember last active tab using cookie
  28. useCookie: true,
  29.  
  30. // open tab on hover
  31. openOnhover: false,
  32.  
  33. // use the history api
  34. useHistory: true,
  35.  
  36. // use keyboard for navigation
  37. keyboardNavigation: true,
  38. // position of tab - top|bottom
  39. tabPosition: 'top',
  40.  
  41. // tab to open initially; start count at 1 not 0
  42. initialTab: 1,
  43.  
  44. // name of the cookie set to remember last active tab
  45. cookieName: 'active-tab',
  46.  
  47. // when it expires in days or standard UTC time
  48. cookieExpires: 365,
  49.  
  50. // path on which cookie is accessible
  51. cookiePath: '',
  52.  
  53. // domain of the cookie
  54. cookieDomain:'',
  55.  
  56. // enable secure cookie - requires https connection to transfer
  57. cookieSecure: false,
  58. // fade|flip|scaleUp|slideLeft
  59. tabInTransition: 'fadeIn',
  60. tabOutTransition: 'fadeOut',
  61. // transitions to use - normal or slide
  62. accordionTransition: 'slide',
  63.  
  64. // time for animation IN (1000 = 1s)
  65. accordionIntime:500,
  66.  
  67. // time for animation OUT (1000 = 1s)
  68. accordionOutTime:400,
  69. // function to call before tab is opened
  70. before: function(){},
  71.  
  72. // function to call after tab is opened
  73. after: function(){}
  74. });

更新日志:

2022-03-30

  • 更新到v2
  • 错误修复

v2.0版本(2015-11-21)

  • 更新jQueryTab.js

v2.0版本(2014-03-20)

  • 添加了带有CSS3转换的版本2
  • 添加了键盘导航和选项卡位置切换

v1.4 (2014-01-31)

  • 几个错误修复和代码优化

预览截图