Gradient borders

后端 未结 17 1454
一个人的身影
一个人的身影 2020-11-22 03:40

I\'m trying to apply a gradient to a border, I thought it was as simple as doing this:

border-color: -moz-linear-gradient(top, #555555, #111111);
         


        
17条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 04:17

    It's a hack, but you can achieve this effect in some cases by using the background-image to specify the gradient and then masking the actual background with a box-shadow. For example:

    p {
      display: inline-block;
      width: 50px;
      height: 50px;
      /* The background is used to specify the border background */
      background: -moz-linear-gradient(45deg, #f00, #ff0);
      background: -webkit-linear-gradient(45deg, #f00, #ff0);
      /* Background origin is the padding box by default.
      Override to make the background cover the border as well. */
      -moz-background-origin: border;
      background-origin: border-box;
      /* A transparent border determines the width */
      border: 4px solid transparent;
      border-radius: 8px;
      box-shadow:
        inset 0 0 12px #0cc, /* Inset shadow */
        0 0 12px #0cc, /* Outset shadow */
        inset -999px 0 0 #fff; /* The background color */
    }
    

    From: http://blog.nateps.com/the-elusive-css-border-gradient

提交回复
热议问题