• 1.模仿卡片翻转效果
  • 2.实现ChatGPT的文字输出效果

模仿卡片翻转效果

效果

实现

1
2
3
4
<div class="card">
<div class="front">前面内容</div>
<div class="back">后面内容</div>
</div>
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
.card {
position: relative;
width: 400px;
height: 100px;
text-align: center;
line-height: 100px;
}

.card:hover .front {
transform: rotateY(-180deg);
}
.card:hover .back{
transform: rotateY(0);
}

.front,
.back {
position: absolute;
width: 100%;
height: 100%;
color: #fff;
border-radius: 10px;
backface-visibility: hidden;
transition: all 1s ease;
}

.front {
background-color: brown;
}

.back {
background-color: darkcyan;
transform: rotateY(180deg);
}