4 gradient borders in CSS

I need help applying a gradient frame on all four sides of the window. I tried, but it only works for two sides. After looking at all the SO links and answers, I got the following:

.test{
  height:250px;
  border: 2px solid;
  border-image: linear-gradient(to left,rgba(78,137,176,1)  1%, rgba(115,192,85,1)  100%) 100% 0 100% 0/2px 0 2px 0;
  padding-top:50px;
}
<div class="test">
  This is a box and I want borders for all the sides
</div>
Run code

I would appreciate any help. I am trying something similar to the image below. Thank.

enter image description here

+4
source share
1 answer

Using a background image: (produces the exact result as an image)

, , , border-image. , background-image, .

, , , , background-position .

- , mimiced. background-origin: border-box border-box ( padding-box content-box). , calc background-position.

.test {
  height: 250px;
  border: 2px solid transparent;
  background-image: linear-gradient(to right, rgb(187, 210, 224), rgb(203, 231, 190)), linear-gradient(to bottom, rgb(114, 191, 87), rgb(116, 191, 86)), linear-gradient(to left, rgb(204, 233, 187), rgb(187, 210, 224)), linear-gradient(to top, rgb(84, 144, 184), rgb(80, 138, 176));
  background-origin: border-box;
  background-size: 100% 2px, 2px 100%, 100% 2px, 2px 100%;
  background-position: top left, top right, bottom right, bottom left;
  background-repeat: no-repeat;
  padding-top: 50px;
}
<div class="test">
  This is a box and i want border for all the side
</div>

: ( 4 , , )

, border-image, , , , , ( ):

.test {
  height: 250px;
  border: 2px solid;
  border-image: linear-gradient(to left, rgba(78, 137, 176, 1) 1%, rgba(115, 192, 85, 1) 100%);
  border-image-slice: 1;
  padding-top:50px;
}
<div class="test">
  This is a box and i want border for all the side
</div>
+9

Source: https://habr.com/ru/post/1670302/


All Articles