Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSS

media query not working with rem

/*
Media query declarations do not base themselves on the declared font-size that you apply to html
and instead always use the default size - 
which is 16px in most browsers

Relative units in media queries are based on the initial value, 
which means that units are never based on results of declarations. 
For example, in HTML, the em unit is relative to the initial value of font-size, 
defined by the user agent or the user’s preferences, not any styling on the page.
*/

html {
  font-size: 10px;
}

@media screen and (min-width: 50rem){ /* 800px (uses base font-size) */
  div.somediv {
    width: 50rem; /* 500px (uses the declared html font-size) */
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #media #query #working #rem
ADD COMMENT
Topic
Name
1+3 =