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

140
Visualizações
Will scrollHeight ever be smaller than clientHeight or offsetHeight?

If I write Math.max(el.scrollHeight, el.offsetHeight, el.clientHeight) will this always equal el.scrollHeight?

Generally, clientHeight <= offsetHeight <= scrollHeight. There are rare cases where clientHeight > offsetHeight for the html element, but I'm not sure if scrollHeight can ever be smaller than the other two.

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

0

The offsetHeight property includes the borders of elements so can definitely be greater than scrollHeight. E.g.

let test = document.getElementById('test');
console.log("clientHeight = " + test.clientHeight);
console.log("offsetHeight = " + test.offsetHeight);
console.log("scrollHeight = " + test.scrollHeight);
console.log("Max Height = " 
    + Math.max(test.scrollHeight, test.offsetHeight, test.clientHeight));
#test {
  height:20px;
  border:0px solid red;
  border-block-width: 20px;
  background-color:blue;
}
<div id="test"></div>

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