Ad

Blend Two Divs At Their Meeting Point

- 1 answer

How can I seamlessly blend the colors of two divs along their meeting point border? Basically looking for a gradient that will roll between them. CSS, JavaScript, pick your poison. Obviously bonus points for CSS.

Tried box-shadow but I can't really control it along their meeting edge as much as I'd like, plus it bleeds all over.

http://jsfiddle.net/q131p8w2/2/

div:nth-child(1) {
    background: skyblue;
    height:150px;
    width:300px;
    margin:0 auto;
}
div:nth-child(2) {
    background: black;
    height:150px;
    width:300px;
    margin:0 auto;
}
Ad

Answer

This snippet could be a lead to something.

div:nth-child(1) {
  color: skyblue;
}
div:nth-chi>div:nth-child(1) {
  color: skyblue;
}
div:nth-child(2) {
  color: black;
}
div {
  position: relative;
  background: currentColor;
  height: 150px;
  width: 300px;
  margin: 0 auto;
}
div:before {
  content: "";
  display: block;
  width: 100%;
  height: 50%;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  transform: translateY(-50%);
  background: linear-gradient(currentColor, transparent);
  pointer-events: none;
}
<div></div>
<div></div>

Ad
source: stackoverflow.com
Ad