1.background-clip

设置元素的背景(背景图片或颜色)是否延伸到边框、内边距盒子、内容盒子下边。共有四个值可用。

  • border-box:默认值,延伸到边框下方
  • padding-box:延伸至内边距外沿,不会绘制到边框处
  • content-box:背景被裁剪至内容区外延
  • text:背景被裁剪为文字的前景色

2.多重边框

  • 实现边框:通过box-shaodw属性的第四个参数,阴影扩张半径来模拟边框效果,当我们只设置扩张半径时,产生的效果相当于一条实线边框。
  • 虚线边框:通过属性outline和对应描边偏移outline-offset来实现。
    1. div:nth-of-type(1) {
    2. width: 60px;
    3. height: 60px;
    4. border-radius: 50%;
    5. background: #fafafa;
    6. margin: 105px 29px;
    7. box-shadow: 0 0 0 10px #bae299, 0 0 0 20px #94b983, 0 0 0 30px #6bb35a,
    8. 0 0 0 40px #59b83c, 0 0 0 50px #49b417, 0 0 0 60px #26bb18,
    9. 0 0 0 70px #31d100, 0 0 0 80px #69f816;
    10. }
    11. div:nth-of-type(2) {
    12. width: 200px;
    13. height: 120px;
    14. background: #efebe9;
    15. border: 5px solid #b4a078;
    16. outline: #b4a078 dashed 1px;
    17. outline-offset: -10px;
    18. margin-bottom: 20px;
    19. }
    image.png image.png

3.边框内圆角

box-shadow会紧贴border-radius圆角边,描边不会与圆角边border-radius贴合,将两者组合,通过box-shadow填补描边outline产生的间隙达到效果。

  1. div {
  2. width: 209px;
  3. margin: 29px auto;
  4. padding: 8px 16px;
  5. border-radius: 8px;
  6. background: #f4f0ea;
  7. outline: 6px solid #b4a078;
  8. box-shadow: 0 0 0 5px #b4a078;
  9. }

image.png

4.background