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

317
Views
Media queries based on Container not Viewport

I am working on an app that has an expandable side bar which, when expanded, shrinks the content container and vice versa when the side bar is closed. I am using media queries to establish my breakpoints, but since media queries are based off of the viewport and not containers, the queries fire too late when the side bar is expanded (The content container is significantly smaller than the viewport when the sidebar is expanded).

Apparently there is a proposed container media query for future spec, but as it does not exist currently, I wanted to ask if there was a way to get around this issue. I'm sure I could use JavaScript to discover the container width and activate css based on that, but I am hopping to avoid that solution as I would have to add that to many components and it seems heavy handed.

Is there a way to base media queries off of container width rather than viewport width?

about 4 years ago · Juan Pablo Isaza
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!