-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsm3test2.html
90 lines (76 loc) Β· 2.01 KB
/
sm3test2.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
* {
margin: 0;
padding: 0;
}
ul {
list-style: none;
}
a {
text-decoration: none;
}
.tab-menu {
display: flex;
}
.tab-menu div {
flex: 1;
cursor: pointer;
text-align: center;
line-height: 50px;
background: #ccc;
transition: .3s;
}
.tab-menu div:hover {
opacity: 0.75;
}
.tab-menu div:not(:first-child) {
border-left: 1px solid #fff;
}
.tab-menu div.on {
background: #f00;
color: #fff;
}
.tab-con {}
.tab-con div {
font-size: 36px;
font-weight: bold;
position: absolute;
opacity: 0;
visibility: hidden;
transition: opacity 1s;
}
.tab-con div.on {
position: relative;
opacity: 1;
visibility: visible;
transition: opacity 1s;
}
</style>
</head>
<body>
<div class="tab-menu">
<div class="on" data-tab="tab1">tab1</div>
<div class="" data-tab="tab2">tab2</div>
<div class="" data-tab="tab3">tab3</div>
</div>
<div class="tab-con">
<div class="on" data-type="tab1">11</div>
<div class="" data-type="tab2">22</div>
<div class="" data-type="tab3">33</div>
</div>
<script>
$('.tab-menu div').click(function () {
tabData = $(this).data('tab');
$(this).addClass('on').siblings().removeClass('on');
$('[data-type=' + tabData + ']').addClass('on').siblings().removeClass('on');
})
</script>
</body>
</html>