DEV Community

Paul Castañeda
Paul Castañeda

Posted on • Edited on

Equal heights

I was working on a landing page website project. There's something I need to evaluate regarding the design of their Figma.

Since the boxes have their different parent and that parent is only displayed as "flex". The only thing that comes to my mind is manipulating them using a script or jQuery. jQuery because that is one library they use from their previous projects and as a developer I need to adapt their environments.

I tried this script.


  function cBoxItemHeight() {
    function getMaxHeight(className) {
      let max = 0;
      document.querySelectorAll(className).forEach(function (el) {

        if (el.scrollHeight > max) {
          max = el.scrollHeight;
        }
      });
      return max;
    }
    function setHeight(className, height) {
      document.querySelectorAll(className).forEach(function (el) {
        el.style.height = height + "px";
      });
    }
    let max = getMaxHeight(".s4__text-coating");
    setHeight(".s4__text-coating", max);
  }
  $(window).resize(function () {
    cBoxItemHeight();
  });
  cBoxItemHeight();

Enter fullscreen mode Exit fullscreen mode

It will save you in the meantime. Hard code it later when you need to think about Vanilla JS. It also helps to follow the design in Figma when resizing the browser.

If you have any ideas. Code your power below.

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (1)

Collapse
 
thedevcristian profile image
Paul Castañeda

UPDATE:

When manipulating the script above the details you have a "fixed" height for the CSS children boxes. Assure you have to change every @media(ratio:ratio){ selector:value here } responsive.
So the children box with the maximum height will be the main height of the other children boxes.

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay