1.转换思路:把阴影当作元素来实现
示例如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文字阴影</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
background-color: #ccc;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
h1 {
font-size: 120px;
font-weight: 700;
}
h1::before {
content: 'SHADOW';
position: absolute;
color: #000;
transform: translate(-50px,20px) scaleY(0.5) skew(50deg);
z-index: -1;
/* 添加模糊效果 */
filter: blur(5px);
/* 遮罩层 使其远模糊,近清晰 */
-webkit-mask: linear-gradient(transparent,#000);
}
</style>
</head>
<body>
<h1>SHADOW</h1>
</body>
</html>
效果图如下: