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

189
Visualizações
get screen size in inches in javascript

Hi guys I have a page that I want to set the initial zoom a little lower on smaller screen sizes, the problem is that I can't get the screen size within javascript, I need to zoom out on screens between 13 and 14 inches but there is no logical way to get that from the pixel values

I have the same problem on mobile, on certain phones the page looks good but on others it doesn't, instead of rebuilding everything I just wanna zoom out

I know it might be bad practice but if there is a way to do it that's what I wanna do

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

0

Inspired by what bZezzz wrote, but with some code to retrieve actual screen dimensions. Also note that screen.availHeight and screen.availWidth return the screen size, and might not be that helpful if your page is being rendered on only a part of the screen.

let hypotenuse = Math.sqrt(screen.availHeight**2 + screen.availWidth**2)
console.log(
  'pixels', hypotenuse,
  'inches', hypotenuse / 96 // Per spec, there are 96 pixels per inch
);

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