主要取决 text-shadow
这个属性
为什么要在最后一次加阴影:为了使3D效果更强烈
为什么要在第二层或者第三次加阴影:因为光线是找不到内部的
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
body {
background-color: rgb(131, 156, 250);
width: 100%;
height: 100%;
}
h1 {
margin: 20% auto;
text-align: center;
font-size: 5rem;
color: white;
text-transform: uppercase; /*大写*/
transition: 0.1s;
}
h1:hover{
text-shadow:
0 1px 0 #ccc,
0 1px 0 rgba(0, 0, 0, 0.2),
0 2px 0 #ccc,
0 2px 0 #ccc,
0 3px 0 #ccc,
0 4px 0 #ccc,
0 5px 0 #ccc,
0 6px 0 #ccc,
0 7px 0 #ccc,
0 8px 0 #ccc,
0 9px 0 #ccc,
0 10px 0 #ccc,
0 11px 0 #ccc,
0 12px 30px rgba(0, 0, 0, 0.5);
}
</style>
</head>
<body>
<h1>3d text</h1>
</body>
</html>