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

134
Visualizações
prevent access to page on small screen

I'm making small web pages for fun and hosting them on my server just to learn stuff and sometimes i send them to some people i know to show them what i've learn but i'd like it so that my web pages aren't accesible to people on small screen. i tried doing

@media (max-width: 800px){
            body{
                height: 0px !important;
                width: 0px !important;
            }
        }

but it didn't work

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

0

Try this:

@media (max-width: 800px) {
    html {
        visibility: hidden;
    }
}
about 4 years ago · Juan Pablo Isaza Relatório

0

@media (max-width: 800px){
            body{
              display:none;
            }
        }
about 4 years ago · Juan Pablo Isaza Relatório

0

A better way to do this is using window.innerWidth.

You can make an onload function that checks the viewport width.

window.onload = () => {
   if (window.innerWidth <= 800) {
   document.body.innerHTML = 'Page not accessible on small screens.'
   } else {
    loadDOM(); /* maybe put [display: none] on body as default and remove it here */
   }
}

This method is better for the user. Atleast they'll know that they have to access the site from a larger device

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