From the HTML5 Boilerplate and originally from Paul Irish:
Change your <html> tag to this:
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
Then IE8 will add a .ie8 class to the html tag. Same for all the other versions of IE. You can then do:
.ie8 {
margin:100px;
}
Edit: Removed the no-js class, and please update the lang="" attribute to your language. Thanks, eyelidlessness.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…