-1

Instead of the entire background of an div being gradient, I want just the "border-left" to be:

http://i.gyazo.com/0e1273fd4f407b767a31b4184fcfe801.png

I'd also like it to be without the colors blending together, as displayed in the picture above.

1 Answers1

2

You can use a pseudo element with a linear gradient background to bottom with stops:

.wrap {
  background: rgba(0,0,0,0.3);
}

.border-test {
  position: relative;
  width: 80px;
  margin: 100px;
  padding: 20px;
  background: white;
}
.border-test::after {
  content: '';
  position: absolute;
  width: 2px;
  left: 5px;
  top: 0;
  bottom: 0;
  background-image: linear-gradient(
  to bottom,
    #ff0000,
    #ff0000 33%,
    #00ff00 33%,
    #00ff00 66%,
    #0000ff 66%
  );
}

Full working demo on codepen here: http://codepen.io/simoncmason/pen/gbeaGB

To get more colours in the band just add more stops at different percentages with more colours.

Simon Mason
  • 561
  • 2
  • 10