【每日一练】01-CSS实现3D菜单效果
发表于:2023-04-17 |
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>【每日一练】01-CSS实现3D菜单效果</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
</head>
<style type="text/css">

*
{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Oswald', sans-serif;
}
body
{
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #434750;
gap: 130px;
}
ul
{
position: relative;
transform: skewY(-15deg);
}
ul li
{
position: relative;
list-style: none;
width: 120px;
padding: 15px;
background: #3e3f46;
z-index: calc(1 * var(--i));
transition: 0.5s;
}
ul li:hover
{
background: var(--clr);
transform: translateX(-50px);
}
ul li::before
{
content: '';
position: absolute;
top: 0;
left: -40px;
width: 40px;
height: 100%;
background: #3e3f46;
filter: brightness(0.7);
transform-origin: right;
transform: skewY(45deg);
transition: 0.5s;
}
ul li:hover::before
{
background: var(--clr);
filter: brightness(0.7);
}
ul li::after
{
content: '';
position: absolute;
top: -40px;
left: 0px;
width: 100%;
height: 40px;
background: #3e3f46;
filter: brightness(0.9);
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
}
ul li:hover::after
{
background: var(--clr);
filter: brightness(0.9);
}
ul li a
{
text-decoration: none;
color: #999;
display: block;
text-transform: uppercase;
letter-spacing: 0.05em;
transition: 0.5s;
}
ul li:hover a
{
color: #fff;
}
ul li:last-child::after
{
box-shadow: -120px 120px 20px rgba(0,0,0,0.25);
}
ul li a span
{
position: absolute;
top: 0;
left: -40px;
width: 40px;
text-align: center;
height: 100%;
transform-origin: right;
transform: skewY(45deg);
transition: 0.5s;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.25em;
opacity: 0.5;
}
ul li:hover a span
{
opacity: 1;
}
</style>
<body>
<ul>
<li style="--i:8;--clr:#00a6bc;"><a href="/"><span><i class="fa fa-caret-right"></i></span> 网站首页</a></li>
<li style="--i:7;--clr:#0a66c2;"><a href="/"><span><i class="fa fa-caret-right"></i></span>HTML/CSS </a></li>
<li style="--i:6;--clr:#1da1f2;"><a href="/"><span><i class="fa fa-caret-right"></i></span>JavaScript</a></li>
<li style="--i:5;--clr:#c32aa3;"><a href="/"><span><i class="fa fa-caret-right"></i></span> 源码案例</a></li>
<li style="--i:4;--clr:#d4620b;"><a href="/"><span><i class="fa fa-caret-right"></i></span> 电子书</a></li>
<li style="--i:3;--clr:#0a66c2;"><a href="/"><span><i class="fa fa-caret-right"></i></span> 在线课程</a></li>
<li style="--i:2;--clr:#d30aa8;"><a href="/"><span><i class="fa fa-caret-right"></i></span> 建站主机</a></li>
<li style="--i:1;--clr:#00a6bc;"><a href="/"><span><i class="fa fa-caret-right"></i></span> 开发工具</a></li>
</ul>
</body>
</html>
上一篇:
clip-path的简单使用
下一篇:
滚动栏效果