Weird gradient border effect

前端 未结 7 532
旧时难觅i
旧时难觅i 2020-11-30 05:33

When applying a transparent border over an element with a linear-gradient as the background, I get a weird effect.

7条回答
  •  迷失自我
    2020-11-30 05:49

    The background is repeating itself under the border. The background runs only in the "body" of the element, under the border is an expansion and repeat starts occurring.

    See this example with no-repeat on the border.

    UPDATE

    Playing with background position & size can help by expanding the background and then adjusting it's location.

    Check this fiddle out.

    Or see snippet:

    .colors {
      padding: 10px;
      width: 100px;
      border: 10px solid rgba(0, 0, 0, 0.2);
      height: 50px;
      background: linear-gradient(to right, #78C5D6, #459BA8, #79C267, #C5D647, #F5D63D, #F08B33, #E868A2, #BE61A5);
      background-size: 117%;
      background-position-x: 130px;
    }

提交回复
热议问题