-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample-info-box.html
170 lines (144 loc) · 4.14 KB
/
sample-info-box.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
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Tabbed info box</title>
<style>
/* General setup */
html {
/* font-family: 'Comic Sans MS',sans-serif; */
scroll-behavior: smooth;
background-color: rgb(217, 255, 227);
font-family: 'Comic Sans MS', 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
ul, ol {
list-style: none;
}
/* info-box setup */
.info-box {
width: 452px;
height: 400px;
margin: 20px auto 0;
}
/* styling info-box tabs */
.info-box ul {
border: 1px solid #b60000;
overflow: hidden;
height: 50px;
margin: 0;
padding: 0;
}
.info-box li {
float: left;
list-style-type: none;
width: 150px;
}
.info-box li a {
display: inline-block;
text-decoration: none;
width: 100%;
line-height: 50px;
background: white;
color: #b60000;
text-align: center;
font-weight: bold;
}
.info-box li a:focus,
.info-box li a:hover {
background-color: #b60000;
color: white;
}
.info-box li a.active-tab {
background-color: #b60000;
color: white;
}
/* styling info-box panels */
.info-box .panels {
clear: both;
position: relative;
height: 352px;
}
.info-box article {
background-color: #b60000;
color: white;
position: absolute;
padding: 10px 20px;
height: 352px;
top: 0;
left: 0;
}
.info-box .active-panel {
z-index: 1;
}
</style>
</head>
<body>
<section class="info-box">
<ul>
<li><a href="#" class="active-tab">Tab 1</a></li>
<li><a href="#">Tab 2</a></li>
<li><a href="#">Tab 3</a></li>
</ul>
<div class="panels">
<article class="active-panel">
<h2>The first tab</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Pellentesque turpis nibh, porttitor nec venenatis eu, pulvinar in
augue. Vestibulum et orci scelerisque, vulputate tellus quis,
lobortis dui. Vivamus varius libero at ipsum mattis efficitur ut nec
nisl. Nullam eget tincidunt metus. Donec ultrices, urna maximus
consequat aliquet, dui neque eleifend lorem, a auctor libero turpis
at sem. Aliquam ut porttitor urna. Nulla facilisi.
</p>
</article>
<article>
<h2>The second tab</h2>
<p>
This tab hasn't got any Lorem Ipsum in it. But the content isn't
very exciting all the same.
</p>
</article>
<article>
<h2>The third tab</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Pellentesque turpis nibh, porttitor nec venenatis eu, pulvinar in
augue. And now an ordered list: how exciting!
</p>
<ol>
<li>dui neque eleifend lorem, a auctor libero turpis at sem.</li>
<li>Aliquam ut porttitor urna.</li>
<li>Nulla facilisi</li>
</ol>
</article>
</div>
</section>
<script>
var tabs = document.querySelectorAll(".info-box li a");
var panels = document.querySelectorAll(".info-box article");
for (i = 0; i < tabs.length; i++) {
var tab = tabs[i];
setTabHandler(tab, i);
}
function setTabHandler(tab, tabPos) {
tab.onclick = function () {
for (i = 0; i < tabs.length; i++) {
tabs[i].className = "";
}
tab.className = "active-tab";
for (i = 0; i < panels.length; i++) {
panels[i].className = "";
}
panels[tabPos].className = "active-panel";
};
}
</script>
</body>
</html>