Search code examples
javascripthtmlcssvue.jsbackground-image

isometric shape background images


I have a design in front of me that looks like this,

enter image description here

As you can see there is a blue square (this right half will be hidden off screen) that overlaps three disticnt sections of a webpage, and I have not how to tackle it.

The only 2 options I can are,

1) Add a portion of the purple square to each of the 3 sections to it merges together, however each section has flexible content so the changes of lining up are slim.

2) Add an absolutely positioned div and position it where i need with the square as a background image and then play with z-indexing?

Is there a simple solution that I am missing?


Solution

  • You can try something like this

    .parent {
      display: flex;
      flex-direction: column
    }
    .card {
      disaply: flex;
      background: darkblue;
      height: 200px;
      width: 350px;
    }
    
    .card2 {
      disaply: flex;
      background: skyblue;
      height: 200px;
      width: 350px;
    }
    
    * {
      margin: 0;
      padding: 10px;
    }
    .diamond {
      height: 150px;
      width: 150px;
      background-color: purple;
      transform: rotate(45deg);
      z-index: 1000;
      margin-left:274px;
      top: 0;
      background: linear-gradient(to left bottom, #ff66ff 50%, #ffe6ff 50%);
    } 
    <div class="parent">
    <div class="card">
      <h1>Item1</h1>
      <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Vero suscipit quisquam, dolor laboriosam fugiat explicabo ipsam dolores.</p>
    <div class="diamond"></div>
    </div>
    
    <div class="card2">
    <h1>Item1</h1>
      <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Vero suscipit quisquam, dolor laboriosam fugiat explicabo ipsam dolores.</p>  
    </div>
    </div>

    https://codepen.io/tonytomk/pen/ExPNWjz