Hauptmenü

Werkzeuge

Kategorien

Archiv

Alle Elemente in einer Spalte gleich hoch wie in allen Spalten

Erstellt in Javascript am 20. Januar 2023 vom Daschmi

window.addEventListener("load", () => {

  window.addEventListener("resize", () => {

    for (const row of document.querySelectorAll('.equal_child_hight')) {

      let arHeight = {};

      for (const col of row.children) {

        for (const el_index in col.children) {

          if (typeof col.children[el_index] === 'object') {

            if (arHeight[el_index] === undefined || arHeight[el_index] < col.children[el_index].getBoundingClientRect().height) arHeight[el_index] = col.children[el_index].getBoundingClientRect().height;

          }

        }

      }

      for (const col of row.children) {
         
        for (const el_index in col.children) {

          if (arHeight[el_index]) col.children[el_index].style.height = arHeight[el_index] + 'px';

        }

      }

    }

  });

});