-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-tabs.html
201 lines (196 loc) · 8.01 KB
/
1-tabs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Javascript</title>
<style>
* {
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
margin: 0;
}
html {
font-size: 14px;
}
body {
font: 14px/1.4 arial;
color: #444;
}
h1, p {
margin-bottom: 1em;
}
hr {
margin: 1em 0;
}
h1:last-child, p:last-child {
margin-bottom: 0;
}
.Container {
width: 1024px;
margin: 2em auto;
}
.TabsHold .Item {
display: inline-block;
padding: 10px 20px;
text-align: center;
background: #ccc;
color: #000;
text-decoration: none;
background: linear-gradient(#eee, #ccc);
/* background: -webkit-linear-gradient(#eee, #ccc);
background: -o-linear-gradient(#eee, #ccc);
background: -moz-linear-gradient(#eee, #ccc); */
border: 1px solid #ccc;
}
.TabContents {
background: #f5f5f5;
padding: 1em;
border: 1px solid #ccc;
margin-top: -1px;
}
.TabsHold {
margin-bottom: 2em;
}
.TabsHold:last-child {
margin-bottom: 0;
}
.TabsHold .TabCont {
display: none;
}
.TabsHold .TabCont.Active {
display: block;
animation: zoom .2s;
-webkit-animation: zoom .2s;
-ms-animation: zoom .2s;
-moz-animation: zoom .2s;
}
.TabsHold .Item.Active, .TabsHold .Item:hover {
background: #f5f5f5;
border-bottom-color: transparent;
}
.TabsHold .TabContents .Item {
display: none;
}
@-webkit-keyframes zoom {
from{
opacity: 0;
transform: scale(0);
}
to{
opacity: 1;
transform: scale(1);
}
}
.TabsHold .TabContents .TabsHold .Item {
display: inline-block;
}
.TabsHold .TabContents .TabsHold .TabContents .Item {
display: none;
}
</style>
</head>
<body>
<div class="Container">
<h1>Multiple tabs and Tab inside tabs</h1><hr/>
<div class="TabsHold">
<div class="TabItems">
<a href="javasript:void(0)" class="Item Active" data-item="one">Tab 1</a>
<a href="javasript:void(0)" class="Item" data-item="two">Tab 2</a>
<a href="javasript:void(0)" class="Item" data-item="three">Tab 3</a>
<a href="javasript:void(0)" class="Item" data-item="four">Tab 4</a>
</div>
<div class="TabContents">
<a href="javasript:void(0)" class="Item Active" data-item="one">Tab 1</a>
<div class="TabCont Active" data-cont="one">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae ab magni, numquam beatae, dolore asperiores eum. Beatae hic perferendis inventore provident minus similique odit ad eaque, at, temporibus, saepe aut?</p>
</div>
<a href="javasript:void(0)" class="Item" data-item="two">Tab 1</a>
<div class="TabCont" data-cont="two">
<div class="TabsHold">
<div class="TabItems">
<a href="javasript:void(0)" class="Item Active" data-item="two_a">Tab 1</a>
<a href="javasript:void(0)" class="Item" data-item="two_b">Tab 2</a>
</div>
<div class="TabContents">
<a href="javasript:void(0)" class="Item Active" data-item="two_a">Tab 1</a>
<div class="TabCont Active" data-cont="two_a">
<p>Tab 1: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae ab magni, numquam beatae, dolore asperiores eum. Beatae hic perferendis inventore provident minus similique odit ad eaque, at, temporibus, saepe aut?</p>
</div>
<a href="javasript:void(0)" class="Item" data-item="two_b">Tab 1</a>
<div class="TabCont" data-cont="two_b">
<p>Tab 2: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque accusamus dolore ipsa vero officia veniam nisi sunt, incidunt maiores error distinctio consequatur qui beatae laudantium earum quo eos! Nobis, nesciunt.</p>
</div>
</div>
</div>
</div>
<a href="javasript:void(0)" class="Item" data-item="three">Tab 1</a>
<div class="TabCont" data-cont="three">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sequi sapiente maxime eum debitis, similique sint praesentium temporibus voluptatum! Quas eius officia dolorem harum sequi unde ab optio corporis, repudiandae. Iusto.</p>
</div>
<a href="javasript:void(0)" class="Item" data-item="four">Tab 1</a>
<div class="TabCont" data-cont="four">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae vero eveniet similique ea facilis consectetur esse quae eos sit et qui consequuntur rem, earum dolorum impedit. In ipsa nihil nulla?</p>
</div>
</div>
</div>
<div class="TabsHold">
<div class="TabItems">
<a href="javasript:void(0)" class="Item Active" data-item="one">Tab 1</a>
<a href="javasript:void(0)" class="Item" data-item="two">Tab 2</a>
<a href="javasript:void(0)" class="Item" data-item="three">Tab 3</a>
<a href="javasript:void(0)" class="Item" data-item="four">Tab 4</a>
</div>
<div class="TabContents">
<a href="javasript:void(0)" class="Item Active" data-item="one">Tab 1</a>
<div class="TabCont Active" data-cont="one">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae ab magni, numquam beatae, dolore asperiores eum. Beatae hic perferendis inventore provident minus similique odit ad eaque, at, temporibus, saepe aut?</p>
</div>
<a href="javasript:void(0)" class="Item" data-item="two">Tab 1</a>
<div class="TabCont" data-cont="two">
<div class="TabsHold">
<div class="TabItems">
<a href="javasript:void(0)" class="Item Active" data-item="two_a">Tab 1</a>
<a href="javasript:void(0)" class="Item" data-item="two_b">Tab 2</a>
</div>
<div class="TabContents">
<a href="javasript:void(0)" class="Item Active" data-item="two_a">Tab 1</a>
<div class="TabCont Active" data-cont="two_a">
<p>Tab 1: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae ab magni, numquam beatae, dolore asperiores eum. Beatae hic perferendis inventore provident minus similique odit ad eaque, at, temporibus, saepe aut?</p>
</div>
<a href="javasript:void(0)" class="Item" data-item="two_b">Tab 1</a>
<div class="TabCont" data-cont="two_b">
<p>Tab 2: Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque accusamus dolore ipsa vero officia veniam nisi sunt, incidunt maiores error distinctio consequatur qui beatae laudantium earum quo eos! Nobis, nesciunt.</p>
</div>
</div>
</div>
</div>
<a href="javasript:void(0)" class="Item" data-item="three">Tab 1</a>
<div class="TabCont" data-cont="three">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sequi sapiente maxime eum debitis, similique sint praesentium temporibus voluptatum! Quas eius officia dolorem harum sequi unde ab optio corporis, repudiandae. Iusto.</p>
</div>
<a href="javasript:void(0)" class="Item" data-item="four">Tab 1</a>
<div class="TabCont" data-cont="four">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Recusandae vero eveniet similique ea facilis consectetur esse quae eos sit et qui consequuntur rem, earum dolorum impedit. In ipsa nihil nulla?</p>
</div>
</div>
</div>
</div>
<script src="js/jquery-3.1.1.min.js"></script>
<script>
$(document).ready(function(){
$('.TabsHold').on('click','.Item',function(){
$(this).closest('.TabItems').find('.Item').removeClass('Active');
$(this).addClass('Active');
var vDataItem = $(this).attr('data-item');
$(this).closest('.TabItems').next('.TabContents').find('.TabCont').removeClass('Active');
$(this).closest('.TabItems').next('.TabContents').find('.TabCont[data-cont='+ vDataItem +']').addClass('Active');
if($(this).closest('.TabItems').next('.TabContents').find('.TabCont[data-cont='+ vDataItem +']').children().hasClass('TabsHold')){
$(this).closest('.TabItems').next('.TabContents').find('.TabCont[data-cont='+ vDataItem +']').children().find('.TabCont:first').addClass('Active');
}
});
});
</script>
</body>
</html>