box-shadow 操蛋玩意

操蛋的地方,在于 blur 阴影的模糊距离,spread设置的阴影大小2个属性,概念有点模糊不清!!!!

1.blur 阴影的模糊距离----到底是什么距离,依我个人理解:比如blur是10px,沿边界内外10px,都模糊;或者说,把内10px的颜色,淡化到内外10px范围内;

所以blur越大,颜色越淡

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>blur</title>
    <style>
        div{
            margin: 20px;
            display: inline-block;
            width: 100px;
            height: 100px;
            background-color: red;
        }
        .box1{
            box-shadow: 100px 100px 20px blue;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
</body>
</html>

spread 表示设置阴影大小-----阴影在原来基础上,往四周扩多少px;

  • 下例中,原本阴影100px*100px,这spread设置100,在原有基础上往四周各扩展100px,变大了
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>spread</title>
    <style>
        div{
            margin: 20px;
            display: inline-block;
            width: 100px;
            height: 100px;
            background-color: red;
        }
        .box1{
            box-shadow: 200px 200px 20px 100px blue;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
</body>
</html>
  • spread 和模糊程度没有关系,只和阴影的面积相关.以下demo中把blur设置为0,更好看spread的概念;
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>spread</title>
    <style>
        div{
            margin: 20px;
            display: inline-block;
            width: 100px;
            height: 100px;
            background-color: red;
        }
        .box1{
            box-shadow: 200px 200px 0px 100px blue;
        }
    </style>
</head>
<body>
    <div class="box1"></div>
</body>
</html>
posted @ 2023-04-17 20:07  盘思动  阅读(9)  评论(0编辑  收藏  举报