Get value from media query - Javascript CSS Style Property

Javascript examples for CSS Style Property:media

Description

Get value from media query

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

@media all and (max-width: 400px), (max-height: 400px) {
   #some-id {//from w  w w  .  j  a v  a 2 s .c  o m
      color: red; 
   } 
}


      </style> 
      <script type="text/javascript">
window.onload=function(){
document.getElementsByTagName('head')[0].style.display = 'block';
document.getElementsByTagName('style')[0].style.display = 'block';

    }

      </script> 
   </head> 
   <body>  
   </body>
</html>

Related Tutorials