How can I find out the height of an HTML block in vmax?

  • 0
    Hello, in general, is it possible to somehow find out the block height in vmax units, and not in px?
    JavaScript Anonymous, Sep 21, 2020

  • 1 Answers
  • 0
    const vmax = element => {
    const rect = element.getBoundingClientRect();
    const denominator = Math.max(innerWidth, innerHeight);

    return {
    width: (rect.width / denominator) * 100,
    height: (rect.height / denominator) * 100
    }
    };


    You just need to add box-sizing: border-box; so that the width / height of the box is correctly calculated in CSS.
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!