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

135
Views
Print only one element with @media print using react

I am having a little drag and drop game, this game has a how-to-play button that opens a modal with text and guides with it, when I click to print( real-life print) I want to show only that one element nothing else. That's where I need your help.

I tried to do this with CSS:

@media print {
  body {
    visibility: hidden;
  }
  .modal-window {
    visibility: visible;
  }
}

Thought this would help but this shows me only a blank page,somehow I need to print only the my Modal.js element which has a div with a class of .modal-window.

If I open the modal (click to the howtoplay button) I get it right, but my task is to do this without clicking on that button.

Thanks

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're hiding body. Your modal window element is in body so it's hidden as well.

Try hiding everything in body except modal window

body *{
    visibility:hidden;
}

body .modal-window {
    visibility: visible;
}
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!