问题
Which css hacks for IE 6 and 7 are future proof? i mean if i use then then they would never create any problem and their patch will never be implemented?
manage 2 css one for all and one for IE is time consuming and it adds one extra style sheet also. and if any hack can solve problem within main css then it's a timesaver and when multiple people work on same project then most of time we forgot to make change in conditional css too.
i'm not asking about condition stylesheet
回答1:
none.
Use IE conditional comments to insert your per-version (no pun intended .. well maybe a little) styles..
[update]
Additional notes to your altered question. It might be time consuming but it is the best-practice (btw many of the hacks are not valid css)..
Using hacks can never be guaranteed, even for the same major versions of a browser .. It is unlikely that they will fix a css bug in IE6 in future minor releases, but still you can not be 100% certain..
There is an alternative (perhaps more time consuming at first), the IE comments i mentioned, but it is truly the best practice...
Besides, think about the other coders in your team who all must know, understand and remember in the future the same hacks.. Over time it will become more time consuming to maintain the hacks than to maintain distinct versions of the offending rules in other files..
回答2:
Hacks are hacks, there is no guarantee whatsoever whether or not they will be future proof. The point is that you should minimize the use of hacks as much as possible, the reason is simple, they can't be future-proof. Don't you see any differences between the hacks of IE6, IE7 and IE8, they all have different hacks, did not retain all hacks from previous versions. Same is true for other browsers.
回答3:
Generally speaking, none are. But nor should they be, special-case coding for spesific browsers isn't a good idea.
If you -do- have to make special-case coding, then your best bet is to use a library like jQuery, and use one of their feature-tests. Don't do "if not IE6", instead do "if not supports-rounded-corners"
回答4:
I can't think about a property starting with an underscore in the future.
_background: #ff0000;
回答5:
Anything that involves overriding a CSS attribute later in the code is just following the CSS standard, and is therefore future-proof.
body {
background: url('background.jpg') center;
background: url('background-top.jpg') top, url('background-bottom.jpg') bottom;
}
However, this only works when using features that aren't available in older browsers, and not when dealing with browser-specific bugs. To ensure specific versions of your CSS are used by specific versions of Internet Explorer, use conditional comments.
<head>
...
<!--[if lt IE 8]><link rel="stylesheet" type="text/css" src="ie7.css" /><![endif]-->
<link rel="stylesheet" type="text/css" src="generic.css" />
</head>
回答6:
Never/always chat aside, the separate file per browser model falls apart quickly over time due to maintenance.
来源:https://stackoverflow.com/questions/2162316/which-css-hacks-for-ie-6-and-7-are-future-proof