Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

132
Views
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 answers
Answer question

0

Try this:

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

0

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

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!