# 倒影

# 元素创建倒影效果 box-reflect

语法:-webkit-box-reflect: <direction> <offset> <mask>;

  • direction(必填):倒影方向
  • offset(必填):倒影距离
  • mask:倒影图像

注意

因为兼容性问题, 前面需要加-webkit

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>box-reflect Demo</title>
    <style>
        .reflect-box {
            width: 200px;
            height: 200px;
            margin: 50px auto;
            background: url("https://picsum.photos/200") no-repeat center/cover;
            border-radius: 12px;

            /* 核心反射效果 */
            -webkit-box-reflect: below 5px linear-gradient(transparent, rgba(0,0,0,0.4));
        }
    </style>
</head>
<body>
<div class="reflect-box"></div>
</body>
</html>