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

185
Views
Is there a way to force a specific media query breakpoint?

Lets say I have css with the styles

@media screen and (min-width: 640px) {
 ...styles go here
}

And I want to force the page to adhere to that specific breakpoint's styles, as in, I want to make it so "the width is always > 640px" regardless of the actual window size. Is there a way to do that in the html, css, or via javascript?

I can't alter the original stylesheet, although I can load in an additional stylesheet or run custom code, but I'd rather not have to essentially copy and past all the styles for this breakpoint if I can avoid that

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

0

A solution would be to duplicate through JavaScript the media query rules for that certain CSSStyleSheet by matching specific conditionText, something like this:

const styles = [];

for (const CSSStyleSheet of document.styleSheets)
    for (const rule of CSSStyleSheet.cssRules)
        if (rule instanceof CSSMediaRule &&
            rule.conditionText === 'screen and (min-width: 640px)') {
            for (const r of rule.cssRules)
                styles.push([CSSStyleSheet, r.cssText]);
        }

styles.forEach(([style, rule]) => style.insertRule(rule));
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!