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 AssemblyAI tool

Transforming Interviews into Publishable Stories with AssemblyAI

Insightview is a modern web application that streamlines the interview workflow for journalists. By leveraging AssemblyAI's LeMUR and Universal-2 technology, it transforms raw interview recordings into structured, actionable content, dramatically reducing the time from recording to publication.

Key Features:
🎥 Audio/video file upload with real-time preview
🗣️ Advanced transcription with speaker identification
⭐ Automatic highlight extraction of key moments
✍️ AI-powered article draft generation
📤 Export interview's subtitles in VTT format

Read full post

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.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay