title: Visibility of a border with three divs
body: <p>I have 3 divs like shown in my code below. In the first and third div I have background colors assigned. The second div contains a white border. The third div is overlapping the first div. Now I want the second div to overlap the third div, but underlap the first div, as shown in the picture. Is there any way to achieve this only using CSS?</p>
  <p>I want a CSS-only solution because the third div can grow, depending on the content, which will be placed inside. Therefore I can't use fix values for the second div's height in order to place the border exactly to the position, where the first and third div meet.</p>
  <p>I can solve it using JavaScript calculating the size of the third div and therefore adjusting the height of the second div, but I want to avoid that because of screen loading issues.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.div1 {
    width: 500px;
    height: 500px;
    background: blue;
    z-index: 1;
    position: relative;
  }
  
  .div2 {
    width: 400px;
    height: 500px;
    border-left: 2px solid #ffffff;
    border-right: 2px solid #ffffff;
    position: absolute;
    z-index: 3;
    top: 0;
  }
  
  .div3 {
    width: 500px;
    height: 250px;
    background: #000000;
    position: absolute;
    bottom: 0;
    z-index: 2;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class ="div1"&gt;&lt;/div&gt;
  &lt;div class ="div2"&gt;&lt;/div&gt;
  &lt;div class ="div3"&gt;&lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/6ytQm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6ytQm.png" alt="enter image description here" /></a></p>