开发者

Which css hacks for IE 6 and 7 are future proof? [duplicate]

This question already has answers here: Detecting IE version using CSS Capability/Feature Detection (18 answers) Closed 2 months ago.

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 i开发者_运维问答t 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


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..


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.


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"


I can't think about a property starting with an underscore in the future.

_background: #ff0000;


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>


Never/always chat aside, the separate file per browser model falls apart quickly over time due to maintenance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜