This is just a quick question for clarification really, I have a style sheet for ie7 and need to call it when someone is browsing via IE7, would the following in my application/layouts file call the ie7 stylesheet?
<!--[if lte IE 7]>
<%= stylesheet_link_tag "ie7", :media => "all" %>
<![endif]-->
Yes, that should only bring in that stylesheet for IE7 and older browsers.
I find it's generally better to add a conditional class to the html tag via the following snippet, and then precede your IE rules with .lt-ieX. This allows you to keep all your related rules together in the same stylesheet.
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
e.g.
.alert {
color: red;
}
.lt-ie7 .alert {
color: blue;
}
Related
I'm on the hunt for a bulletproof workflow for select menus. I have conditional comments for ie 10+
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
<!--[if IE 9]> <html class="ie ie9 lte9"> <![endif]-->
<!--[if gt IE 9]> <html class="gt9"> <![endif]-->
<!--[if !IE]><!--> <html> <!--<![endif]-->
And Chrome does just fine when it comes to hiding/showing select arrows with:
-webkit-appearance: none;
However when it comes to Firefox:
-moz-appearance:none;
Works for versions 35+. This means that FF<35 will display both my custom background-image arrow and its default on select menus. So hiding the dropdown arrow for these legacy browsers is the final hurdle to a cross browser solution.
How do I target background-image for Firefox browsers older than version 35?
I know modernizer or other libraries may be able to do so but that's overkill to add a class name to < html> or a vendor specific pseudo element I don't know about. Thanks in advance.
You could use JavaScript to detect the version.
var frags = navigator.userAgent.split('/');
if ((frags[frags.length - 2].indexOf('Firefox') > -1) && (parseFloat(frags[frags.length - 1]) < 35)) {
alert('You are on Firefox version < 35')
}
I am wondering if there is a way to conditionally import CSS files for IE7/8 at the CSS level instead of using IE conditional comments.
I'd like to create a SASS solution for loading Google Fonts, but to make them work in IE7/8 requires that different styles be loaded separately. This however is undesired when not needed due to latency and Opera rendering issues.
I am unaware of another way of conditional loading IE specific styles. You've got two options but both use conditional comments.
Load a separate stylesheet
<!--[if lt IE 9]>
<style type="text/css" src="bacon-ie.css"> </style>
<![endif]-->
Add IE class names
<!--[if IE 7]> <html class="ie7" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="ie8" lang="en"> <![endif]-->
<!--[if IE 9]> <html class="ie9" lang="en"> <![endif]-->
<!--[if gt IE 9]><!-->
<html lang="en">
<!--<![endif]-->
And then use them to add specific browser styles.
.ie7 .make-work {
zoom: 1;
}
I have style sheet file and would like to disable some css tags in it for IE7 and IE8 browsers, how to do that? I do not want to put these tabs in separated css file I would like to keep then in one file.
I'd recommend the approach taken by the HTML5 boilerplate, outlined here by Paul Irish. Basically, set up your document like this:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
You now have classes in place to accurately target only certain versions of IE. Your css will look like this:
.element { margin-bottom: 20px; }
.lt-ie8 .element { margin-bottom: 10px; }
You then avoid CSS hacks, and can keep everything in a single stylesheet.
As #Daniel states, this is not disabling styles, but over-riding them. If for some reason you want to send styles to only modern browsers and newer IE, you could add another class to the final html tag above, and use that.
If you try to have specific style-sheets only for IE it goes like this:
<!--[if IE 8]><link rel="stylesheet" href="css/ie8.css" type="text/css" media="screen"><![endif]-->
<!--[if IE 7]><link rel="stylesheet" href="css/ie7.css" type="text/css" media="screen"><![endif]-->
<!--[if IE]><link rel="stylesheet" href="css/ie.css" type="text/css" media="screen"><![endif]-->
More about this here: How To Create an IE-Only Stylesheet
.element {
margin-bottom: 20px;
margin-bottom: 10px\9;
}
Info from here: http://www.impressivewebs.com/ie7-ie8-css-hacks/
You cannot disable them, but you can override them
Without:
adding any markup element there;
without using display: inline-block;
without knowing the div width;
no hacks. the code should validate.
How can we center those three divs horizontally, but making them INLINE ?
http://jsfiddle.net/mMPMh/
Please note:
The reason that I'm avoiding inline-block, lies on the fact that IE7 should behave.
Other rules that don't work on IE 7 should also be disregarded.
Is it possible ?
Like this - http://jsfiddle.net/mMPMh/10/
Or this - http://jsfiddle.net/mMPMh/14/ ?
This one works with IE7
As for hacks, it can be served using conditional statement like
<!--[if lt IE 8]>
<link rel="stylesheet" type="text/css" href="ie7-and-down.css" />
<![endif]-->
Or using this on your HTML (from HTML5BP)
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
And serve the style like this :
.lt-ie8 #one,
.lt-ie8 #two,
.lt-ie8 #three {
display:inline;
zoom:1;
}
No hacks
UPD:
After you update your questionyou can use for IE display:inline;, maybe it will resolve your issue?
Like this - http://jsfiddle.net/mMPMh/4/ ?
remove float, set clear, and give if you need height and width.
I don't mean conditional comments embedded into the html. I am refering to the conditional code that can be put directly into the css file. Like:
*+html .myClass {} is for IE7
* html .myClass {} is for IE 6
what is the one for IE 8?
What are you trying to achieve? You shouldn't have to hack up your CSS for IE8. I don't think there is a conditional code for IE8 so if you absolutely need to have a style sheet for IE8, you might have to turn to conditional comment.
<!--[if IE 8]>
<link href="ie8css.css" rel="stylesheet" type="text/css" />
<![endif]-->
Conditional comment for the HTML tag, which will allow you to target .ie8 in your CSS:
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
That is what's currently being used in html5boilerplate.
Also, be weary of the last few paragraphs in Paul's blog post. I agree that you should try to make it work without targeting specific browsers, it at all possible.
According to this site, you can do the following:
.selector {
property: value\0/;
}
There are several similar variants of this hack, but this is the easiest. It’s very easy to remember. Just add the \0/ at the end of a CSS rule.