image.png

    这里做出几点解释:

    • 首先offset-x,offset-y可以理解为偏移量,分为两种情况解释。第一inset,此时外部可以认为是全部shadow色,offset取色来则于外部;第二,正常情况,默认大小和元素相同,shadow发散自原元素,偏移后会将整体进行移动。
    • image.png
      1. div {
      2. width: 100px;
      3. height: 100px;
      4. background: #3699ff;
      5. box-shadow: inset 30px 0px 10px red;
      6. }
      阴影向内发散,偏移后从外部取色(可以理解为蓝色元素外部是红色的大海)

    image.png

    1. div {
    2. width: 100px;
    3. height: 100px;
    4. background: #3699ff;
    5. box-shadow: 30px 0px 10px red;
    6. }

    阴影向外发散,如果0 0 0 那就会被盖住,偏移效果一目了然

    • 参数blur-radius控制模糊程度,对应blur
    • 参数spread-radius控制阴影大小

    image.png

    1. div {
    2. width: 100px;
    3. height: 100px;
    4. background: #3699ff;
    5. box-shadow: 0px 0px 0px 10px red;
    6. }

    阴影的对应容器变大了

    增加按钮特效
    image.png

    1. button {
    2. position: relative;
    3. display: flex;
    4. align-items: center;
    5. justify-content: center;
    6. width: 43px;
    7. height: 43px;
    8. padding: 0;
    9. background: rgba(46, 50, 52, 1);
    10. border: none;
    11. border-radius: 50%;
    12. box-shadow: -1px -1px 3px rgba(255, 255, 255, 0.14), 2px 2px 6px rgba(0, 0, 0, 1);
    13. img {
    14. width: 15px;
    15. height: 17px;
    16. }
    17. p {
    18. position: absolute;
    19. bottom: -9px;
    20. width: 50px;
    21. margin: 0 auto;
    22. color: rgba(184, 184, 184, 1);
    23. font-weight: 500;
    24. font-size: 12px;
    25. font-family: SourceHanSans-Medium;
    26. line-height: 18px;
    27. }
    28. }
    29. button:active {
    30. box-shadow: inset -1px -1px 3px rgba(255, 255, 255, 0.14), inset 2px 2px 6px rgba(0, 0, 0, 1);
    31. }
    32. button:focus {
    33. outline: none;
    34. }