-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoverTabs.html
87 lines (85 loc) · 2.85 KB
/
hoverTabs.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Hoverable Vertical Tabs</title>
<style>
*{
margin: 0;
padding: 0;
font-family: poppins;
}
.tab{
float: left;
width: 20%;
height: 300px;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
.tablinks{
border: none;
outline: none;
background-color: inherit;
padding: 22px 16px;
width: 100%;
color: black;
font-size: 17px;
float: left;
display: block;
text-align: left;
cursor: pointer;
}
.tab button:hover{
background-color: #ddd;
}
.tab button.active{
background-color: #ccc;
}
.tabcontent{
height: 300px;
width: 70%;
float: left;
padding: 0px 12px;
border-left: none;
display: none;
border: 1px solid #ccc;
}
h2{
font-size: 3rem;
}
</style>
</head>
<body>
<!-- Tab links -->
<div class="tab">
<button class="tablinks" onmouseover="openCity(event,'London')" id="default">London</button>
<button class="tablinks" onmouseover="openCity(event,'Paris')">Paris</button>
<button class="tablinks" onmouseover="openCity(event,'Tokyo')">Tokyo</button>
</div>
<!-- Tab content -->
<div id="London" class="tabcontent"><h2>London</h2><p>London is the capital city of England.</p></div>
<div id="Paris" class="tabcontent"><h2>Paris</h2><p>London is the capital of France.</p></div>
<div id="Tokyo" class="tabcontent"><h2>Tokyo</h2><p>London is the capital of Japan.</p></div>
<!-- script -->
<script>
function openCity(evt,cityName){
var i,tablinks,tabcontent;
// Hide all the elements with class = "tabcontent"
tabcontent= document.getElementsByClassName("tabcontent")
for(i=0;i<tabcontent.length;i++){
tabcontent[i].style.display= "none";
}
// Get all the tablinks and remove the class active from them
tablinks= document.getElementsByClassName("tablinks");
for(i=0;i<tablinks.length;i++){
tablinks[i].className.replace(" active","");
}
// Show the current tab
document.getElementById(cityName).style.display= "block";
evt.currentTarget.className+= " active";
}
</script>
</body>
</html>