Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
How to determine with what values is a div overflowing in all the directions?

I would like to know if there is any way by which I can determine with what quantities a div is overflowing in any direction. Searches in the internet only took me to the point where I can figure out the total horizontal or vertical values with which a div is overflowing. But, I wanted to know the exact top, right, bottom, left values.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can use getBoundingClientRect and compute value on DOMRect value.

This API has a good browser support.

Inside a Reactjs component you should use ref for access to div at phisycal DOM.

import React from 'react';

const Foobar = () => {

  const onRef = (element) => {

    const domRect = element.getBoundingClientRect();
    
    console.log(`
        quantity before overflow top: ${domRect.y}px
        quantity before overflow left: ${domRect.x}px
        quantity before overflow right: ${window.screen.width - domRect.right}px
        quantity before overflow bottom: ${window.screen.height - domRect.bottom}px
    `);
  };
  
  return (
    <div ref={onRef}>
      {# ... #}
    </div>
  );

}

export default Foobar;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda