简体   繁体   中英

css stylesheet on IE8, IE9

I´m working on a web application, now the css is working perfectly with Opera, Chrome, Firefox and Safari. I just have some specific problems with IE8 and IE9. My doubt is, what is the best choice, write an exclusive css for IE or just incorporate specific lines for IE?

This works with Chrome, Firefox, Safari and Opera:

#table{
    width: 60%;
    margin-top: 60px;
    margin-left: auto;
    margin-right:  auto;
}

Code for explorer:

#table{
    width: 60%;
    margin-top: 60px;
    margin-left: 20%;
    margin-right:  auto;
}

I´m looking for the fastest choice on load. Thanks in advance.

I find it easiest to isolate the tweaks into an IE-specific stylesheet, and then use conditional comments (which only IE understands anyway) to load them after the normal CSS.

Here's an example from one project of mine (an ASP.NET MVC2 project):

<!--[if lte IE8]>
<link rel="stylesheet" type="text/css" href="<%: Url.Content("~/content/ie-fix.css") %>" />
<![endif]-->

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM