jQuery 如何使用 Twitter Bootstrap 框架淡入和淡出标签?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8915602/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 11:15:08  来源:igfitidea点击:

How can I fade tabs in & out with the Twitter Bootstrap framework?

jquerytabstwitter-bootstrap

提问by Travis Northcutt

jQuery UI has the option to initialize tabs with the tabs set to fade in/out, like so:

jQuery UI 可以选择使用设置为淡入/淡出的选项卡来初始化选项卡,如下所示:

$(".selector").tabs({ fx: { opacity: 'toggle' } });

Is something similar possible with the Twitter Bootstrap framework tabs?

Twitter Bootstrap 框架选项卡是否有类似的可能?

采纳答案by Sinetheta

No, but you could add your own, jsFiddle

不,但您可以添加自己的jsFiddle

$('.tabs').tabs()
    .bind('change', function (e) {
        $(this).next().hide().fadeIn();
    });

回答by baxang

Both for Bootstrap 2 and 3, you can simply give your .tab-paneelements a fadeclass with bootstrap-transition.jsloaded. No need to write a single line of your own JavaScript code at all.

对于 Bootstrap 2 和 3,您可以简单地为您的.tab-pane元素提供一个加载的fadebootstrap-transition.js。根本不需要编写一行您自己的 JavaScript 代码。

<div class="tab-content">
  <div class="tab-pane fade in active" id="home">...</div>
  <div class="tab-pane fade" id="profile">...</div>
  <div class="tab-pane fade" id="messages">...</div>
  <div class="tab-pane fade" id="settings">...</div>
</div>

Code sample from the official Twitter Bootstrap documentation.

来自官方 Twitter Bootstrap 文档的代码示例。