console
; (function(defaults, $, window, document, undefined) {
'use strict';
$.extend({
tabifySetup: function(options) {
return $.extend(defaults, options);
}
}).fn.extend({
tabify: function(options) {
options = $.extend({},
defaults, options);
return $(this).each(function() {
var $element, tabHTML, $tabs, $sections;
$element = $(this);
$sections = $element.children();
tabHTML = '<ul class="tab_nav">';
$sections.each(function() {
if ($(this).attr("title") && $(this).attr("id")) {
tabHTML += '<li><a href="#' + $(this).attr("id") + '">' + $(this).attr("title") + '</a></li>';
}
});
tabHTML += '</ul>';
$element.prepend(tabHTML);
$tabs = $element.find('.tab_nav li');
var activateTab = function(id) {
$tabs.filter('.active').removeClass('active');
$sections.filter('.active').removeClass('active');
$tabs.has('a[href="' + id + '"]').addClass('active');
$sections.filter(id).addClass('active');
}
$tabs.on('click', function(e) {
activateTab($(this).find('a').attr('href'));
e.preventDefault();
});
activateTab($tabs.first().find('a').attr('href'));
});
}
});
})({
property: "value",
otherProperty: "value"
},
jQuery, window, document);
$(function() {
$('.tab_group').tabify();
})
<div class="container">
<div class="tab_group">
<section id="tab1" title="模块一">
<h3>
content one
</h3>
<div class="tab_menu">
<ul>
<li>
人总是要为自己年少无知时犯的错买单。
</li>
<li>
只有触摸历史经纬里的铮铮铁骨,才能感受那段真实清晰的岁月。
</li>
<li>
一个人要成长的话,你的记忆一定要健全,一个民族要成长,记忆也一定要健全。
</li>
</ul>
</div>
</section>
<section id="tab2" title="模块二">
<h3>
content two
</h3>
<div class="tab_menu">
<ul>
<li>
人生是一场难得的修行,不要轻易交白卷。
</li>
<li>
明天和意外,永远猜不透哪个先来。
</li>
<li>
我要在死亡的阴影里,热烈地活着。
</li>
<li>
一个人真正的劫后余生,是心的复活。
</li>
<li>
如果皮囊难以修复,那就用思想去填满它。
</li>
</ul>
</div>
</section>
<section id="tab3" title="模块三">
<h3>
假如生活欺骗了你
</h3>
<p>
《假如生活欺骗了你》是俄国诗人普希金于1825年流放南俄敖德萨同当地总督发生冲突后,被押送到其父亲的领地米哈伊洛夫斯科耶村幽禁期间创作的一首诗歌。诗歌全文表述了一种积极乐观而坚强的人生态度,并且因它亲切和蔼的口气让许多人把它记于自己的笔记本上,成为了激励自己勇往直前,永不放弃的座右铭。
</p>
<div class="tab_menu">
<ul>
<li>
假如生活欺骗了你,
</li>
<li>
不要悲伤,不要心急!
</li>
<li>
忧郁的日子里须要镇静:
</li>
<li>
相信吧,快乐的日子将会来临!
</li>
<li>
心儿永远向往着未来;
</li>
<li>
现在却常是忧郁。
</li>
<li>
一切都是瞬息,一切都将会过去;
</li>
<li>
而那过去了的,就会成为亲切的怀恋。
</li>
</ul>
</div>
</section>
<section id="tab4" title="模块四">
<h3>
我爱这土地
</h3>
<p>
选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换选项卡切换
</p>
<div class="tab_menu">
<ul>
<li>
假如我是一只鸟,
</li>
<li>
我也应该用嘶哑的喉咙歌唱:
</li>
<li>
这被暴风雨所打击着的土地,
</li>
<li>
...
</li>
<li>
为什么我的眼里常含泪水?
</li>
<li>
因为我对这土地爱得深沉……
</li>
</ul>
</div>
</section>
</div>
</div>
@charset "utf-8";
.container:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
*,
*:before,
*:after {
box-sizing: border-box;
}
.container {
position: relative;
background: white;
padding: 1em 3em;
}
.tab_group {
position: relative;
border: 1px solid #eee;
margin-top: 2.5em;
border-radius: 0 0 10px 10px;
}
.tab_group section {
opacity: 0;
height: 0;
padding: 0 1em;
overflow: hidden;
transition: opacity 0.4s ease, height 0.4s ease;
}
.tab_group section.active {
opacity: 1;
height: auto;
overflow: visible;
}
.tab_group section h3 {
line-height: 3em;
font-weight: bold;
}
.tab_menu {
height: 160px;
padding: 0.2em 1.6em;
}
.tab_menu ul li {
list-style: circle;
}
.tab_nav {
list-style: none;
margin: -2.5em -1px 0 0;
padding: 0;
height: 2.5em;
overflow: hidden;
}
.tab_nav li {
display: inline;
}
.tab_nav li a {
top: 1px;
position: relative;
display: block;
float: left;
border-radius: 10px 10px 0 0;
background: #EEEEEE;
line-height: 2em;
padding: 0 1em;
text-decoration: none;
color: grey;
margin-top: 0.5em;
margin-right: 1px;
transition: background 0.2s ease, line-height 0.2s ease, margin 0.2s ease;
}
.tab_nav li.active a {
background: #49c8f2;
color: white;
line-height: 2.5em;
margin-top: 0;
}
.content {
width: 620px;
background-color: #ffffff;
padding: 20px;
}
.container h1 {
color: #221A69;
font-weight: normal;
text-decoration: none;
}
.tabbed_content {
background-color: #000000;
width: 620px;
}
.container .tabs {
height: 62px;
position: relative;
}
.tabs .moving_bg {
padding: 15px;
background-color: #7F822A;
background-image: url(../img/arrow_down_green.gif);
position: absolute;
width: 125px;
z-index: 190;
left: 0;
padding-bottom: 29px;
background-position: bottom left;
background-repeat: no-repeat;
}
.tabs .tab_item {
display: block;
float: left;
padding: 15px;
width: 125px;
color: #ffffff;
text-align: center;
z-index: 200;
position: relative;
cursor: pointer;
}
.tabbed_content .slide_content {
overflow: hidden;
background-color: #000000;
padding: 20px 0 20px 20px;
position: relative;
width: 600px;
}
.tabslider {
width: 5000px;
}
.tabslider ul {
float: left;
width: 560px;
margin: 0px;
padding: 0px;
margin-right: 40px;
}
.tabslider ul a {
color: #ffffff;
text-decoration: none;
}
.tabslider ul a:hover {
color: #aaaaaa;
}
.tabslider ul li {
padding-bottom: 7px;
}