Media Query Enqueue Conditional CSS & Stylesheets
-
Please help!
I am trying to develop a mobile first site and want to use stylesheets conditionally.
In html, here is my goal (via Brad Frost at https://www.html5rocks.com/en/mobile/responsivedesign/):
<link rel="stylesheet" type="text/css" href="style.css" media="screen, handheld" /> <link rel="stylesheet" type="text/css" href="enhanced.css" media="screen and (min-width: 40.5em)" /> <!--[if (lt IE 9)&(!IEMobile)]> <link rel="stylesheet" type="text/css" href="enhanced.css" /> <![endif]-->
So in WP:
In functions.php I want to use the following:
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'enhanced', get_stylesheet_uri() . '/styles/enhanced.css', 'css', true );
Is it possible to put conditions on the enqueue_style? Can I do the first line by media=”screen, handheld” and the second line by media=”screen and (min-width: 40.5em”? How?
I can’t find anything on this on the interwebs. I will be HUGELY grateful for any help on this!
Thank you!
Joe Snell
- The topic ‘Media Query Enqueue Conditional CSS & Stylesheets’ is closed to new replies.