JavaScript How can I create overlapping trapezoids or successive rhombus from array?

I have been working on this for a while and would love some help. I have two sets of divs of different lengths offset by varying distances which are being created from an array.

Fiddle 1: JSFiddle1

Between these sets of divs I would like to dynamically create a connecting shape (trapezoid/rhombus like shape). I was able to create the first one using CSS and borders.

Fiddle 2: JSFiddle2

When I try to add successive divs I run into a problem.

Fiddle 3: JSFiddle3

The goal would look something like this (but created dynamically from the array rather than my Photoshopping here):

Photoshop Image of Goal

Any ideas?

I am not concerned about crossbrowser (I am only using FF), though such might be nice if it is easy.

Answer:1

I know you wanted an HTML and CSS based solution, but here is a JavaScript solution for generating a svg based solution:

var correlationPoints = [
    [0, 10, 50, 200, 600],
    [0, 200, 300, 400, 600]
  ],
  correlationHeight = 16,
  svg = document.getElementsByTagName('g')[0],
  patches = correlationPoints[0].length;

for (var i = 0; i < correlationPoints[0].length - 1; i++) {
  var newElement = document.createElementNS("http://www.w3.org/2000/svg", 'path'),
    color = Math.round(((i + 1) / patches) * 255),
    path = [],
    c = 0;

  newElement.setAttribute('fill', 'RGB(' + color + ',' + color + ',' + color + ')');
  path[c++] = 'M'; // start move
  path[c++] = correlationPoints[0][i]; // start at top left corner x
  path[c++] = '0'; //top left y

  path[c++] = 'L'; //top right
  path[c++] = correlationPoints[0][i + 1];
  path[c++] = '0';

  path[c++] = 'L'; // top of angle right
  path[c++] = correlationPoints[0][i + 1];
  path[c++] = '20';

  path[c++] = 'L'; // bottom of angle right
  path[c++] = correlationPoints[1][i + 1];
  path[c++] = '40';

  path[c++] = 'L'; // bottom right
  path[c++] = correlationPoints[1][i + 1];
  path[c++] = '60';

  path[c++] = 'L'; // bottom left
  path[c++] = correlationPoints[1][i];
  path[c++] = '60';

  path[c++] = 'L'; // bottom of angle left
  path[c++] = correlationPoints[1][i];
  path[c++] = '40';

  path[c++] = 'L'; // top of angle left
  path[c++] = correlationPoints[0][i];
  path[c++] = '20';

  newElement.setAttribute("d", path.join(' '));
  svg.appendChild(newElement);
}
body {
  margin: 20px;
  background-color: lightblue;
}

path:hover {
  fill: red;
}
<h1>Title</h1>
<p>Regular text.</p>
<svg xmlns="http://www.w3.org/2000/svg" width="600px" height="60px">
    <desc></desc>
    <g class="correlations" alignment-baseline="baseline">
    </g>
</svg>
<p>Regular text.</p>
Answer:2

as you can see here jsfiddle.net/TTU4Z/1/ The jquery code in question is below and if i run it without all my code (like in jsfiddle) it run perfectly. but with all my code doesn't run. $(document)....

as you can see here jsfiddle.net/TTU4Z/1/ The jquery code in question is below and if i run it without all my code (like in jsfiddle) it run perfectly. but with all my code doesn't run. $(document)....

  1. plus minus button excel
  2. plus minus button html
  3. plus minus button javascript
  4. plus minus button on calculator
  5. plus minus button on gear shifter
  6. plus minus button on acadia shifter
  7. plus minus button in android
  8. plus minus button bootstrap
  9. plus minus button jquery
  10. plus minus button angular
  11. plus minus button codepen
  12. plus minus button php
  13. plus minus button w3schools
  14. plus minus button in bootstrap 4

I want to call my function in php from java script or jquery. I have tried this. <script> function hello(){ <?php print_hello(); ?> } hello()...

I want to call my function in php from java script or jquery. I have tried this. <script> function hello(){ <?php print_hello(); ?> } hello()...

  1. vue call function in created

My Code is: $rootScope.getResource = function(id) { $http.get( "path/of/resource/" + id ) .success(function (data, status, header, config) { return data; }) .error(function (data, ...

My Code is: $rootScope.getResource = function(id) { $http.get( "path/of/resource/" + id ) .success(function (data, status, header, config) { return data; }) .error(function (data, ...

I want to draw the road map when i select the few location using check boxes in form.php. I post that locations into map.php file, I assign that posted values into $location array and now I want to ...

I want to draw the road map when i select the few location using check boxes in form.php. I post that locations into map.php file, I assign that posted values into $location array and now I want to ...