Keep using min-width css queries, and output a special stylesheet just to placate IE8 (and below).
IE8 is the problem. Hopefully it's going away, but it hasn’t yet for a lot of businesses. Especially publishers, who are looking to reach a wide audience. IE8 Just doesn’t recognize media queries. Anything inside them is ignored.
- Don’t support IE8.
- Non-support is unacceptable for a lot of clients
- If ignored, IE8 will serve your mobile styles (everything outside a media query). This can result in a very sub-optimal user experience unless very carefully accounted for.
- If we use max-width, IE8 gets styles for a monitor resolution its users are unlikely to have. Plus, max-width.
- If we use a combination of min and max width we make a hot mess out of our stylesheets, piss off all future front-end engineers, and play right into the hands of the evil league of evil.
- Respond.js or other polyfills
- Reads all css into javascript, manipulates and injects CSS based on every resize event.
- “lightweight” ha. no. This is heavy.
- But hey, it’s a drop-in solution and sometimes the right thing.
- DOES NOT WORK ON VIP. May not work on other CDNs as well.
The solution we are looking for:
- Does not try to impose responsive design on a browser that does not support responsive design
- Goldilocks sizing (not to small, mobile, not to big, uber desktop)
- Does not require any real workflow changes. You’re still developing for modern browsers.
- Determine the size of screen you want to target for IE8.
- Most common horizontal resolution in analytics, probably
- Don’t worry you can change it later
- Use IE conditionals to enqueue a stylesheet just for <= IE8 and another different for everyone else.
- Go about your business, but use a media query mixin
- The IE8 stylesheet won’t print any media queries, it will print the styles if the media query is for <= the target screen size.
There are two stylesheets that result from this system. One for <= IE8 and one for everyone else except <= IE8. This requires an IE conditional tag done twice.
<!--[if lte IE 8]>
<link rel="stylesheet" href="css/global-old-ie.css">
<![endif]-->
<!--[if gt IE 8]><!-->
<link rel="stylesheet" href="css/global.css">
<!--<![endif]-->
WordPress supports standard IE conditionals — such as the one for enqueing global-old-ie.css, above — but it does not support the format used to enqueue global.css. A workaround can be developed using the style_loader_tag
filter (see index.html for the code) or you may decide to pull those two files out of the enqueue system completely and ouput the tags directly via the wp_print_styles
hook.