For browsers < IE7, I want to use a certain style attribute, while for other browsers I'd like to use another. Can I do this using a single css file, or do I have to do if then logic to include an ie hack css file?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
You can use CSS Expressions to some extent.
See http://gadgetopia.com/post/2774 for some examples. These don't get around conditional CSS attributes per se, but they do allow you to dynamically vary the values of CSS attributes.
Here's an example how you can include an IE6-specific CSS to override specific CSS classes for IE 6 or lower:
Alternatively, you can do it on per-element basis like this:
MSDN has some more details about IE Conditional Comments support.
You could use CSS hacks. But you shouldn't.
The following page will show you 6 CSS hacks specifically for IE7. You shouldn't use them, but they're the easiest way for getting the exact right look for your website.
You could use conditional comments:
I've found it to be the cleanest solution for this kind of thing.
on the jQuery tip check out this plugin: http://jquery.thewikies.com/browser/
a plugin to do what ghills suggests, this is a nice clean way to go.