# tab动画
# 动画一
- tab1
- tab2
- tab3
- tab4
- tab5
- tab6
<ul class="tabs">
<li>tab1</li>
<li>tab2</li>
<li>tab3</li>
<li>tab4</li>
<li>tab5</li>
<li>tab6</li>
</ul>
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
.tabs {
display: flex;
justify-content: center;
align-items: center;
li {
height: 40px;
line-height: 40px;
padding: 0 15px;
cursor: pointer;
position: relative;
font-size: 18px;
color: #909399;
background-color: #fff;
&::after {
content: "";
width: 0;
height: 2px;
background-color: #00adb5;
position: absolute;
left: 100%;
bottom: 0;
transition: all .4s;
}
&:hover {
color: #00adb5;
&::after {
width: 100%;
left: 0;
transition-delay: 0.1s;
}
& ~ li::after {
left: 0;
}
}
}
}
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
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
# 动画二
- tab1
- tab2
- tab3
- tab4
- tab5
<ul class="tabs">
<li class="tab-item" v-for="n in 5"
:class="{active:isActive==n}"
@click="setActive(n)">tab{{n}}
</li>
</ul>
1
2
3
4
5
6
2
3
4
5
6
.tabs {
display: flex;
justify-content: center;
align-items: center;
li {
height: 40px;
line-height: 40px;
padding: 0 15px;
cursor: pointer;
position: relative;
font-size: 18px;
color: #909399;
background-color: #fff;
&::after {
content: "";
width: 0;
height: 2px;
background-color: #00adb5;
position: absolute;
left: 0;
right: 0;
margin: auto;
bottom: 0;
transition: width .4s;
}
&:hover::after{
width: 100%;
}
}
li.active {
&::after {
width: 100%;
}
}
}
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
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