MVC 中仅 IE7 样式表

发布于 2024-12-13 00:44:25 字数 524 浏览 4 评论 0原文

我的 ASP.net MVC 项目中需要一个仅适用于 IE7 的样式表。

执行此操作的更好方法是什么:

<!--[if IE 7]><link href="@Url.Content("~/Content/IE7.css")" rel="stylesheet" type="text/css" /><![endif]-->

或者

@if(Request.Browser.Browser == "IE" && Request.Browser.MajorVersion >= 7 && Request.Browser.MajorVersion < 8) {
    <link href="@Url.Content("~/Content/IE7.css")" rel="stylesheet" type="text/css" />
}

是否有在 MVC 中执行此操作的首选方法,或者它们几乎相同?

I need an IE7 only stylesheet in my ASP.net MVC project.

What is the better approach to doing this:

<!--[if IE 7]><link href="@Url.Content("~/Content/IE7.css")" rel="stylesheet" type="text/css" /><![endif]-->

OR

@if(Request.Browser.Browser == "IE" && Request.Browser.MajorVersion >= 7 && Request.Browser.MajorVersion < 8) {
    <link href="@Url.Content("~/Content/IE7.css")" rel="stylesheet" type="text/css" />
}

Is there a preferred way to do this in MVC or are they pretty much equal?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜唯美灬不弃 2024-12-20 00:44:25

你的两个选择会做完全不同的事情。第一个,[if IE 7]浏览器决定渲染什么。第二个让服务器决定。

第一个将使用缓存层,假设所有浏览器应该看到相同的标记。第二个不会。

另外,请考虑 Modernizr 而不是推出自己的 IE 7 支持。

Your two options do totally different things. The first, [if IE 7] lets the browser decide what to render. The second makes the server decide.

The first will work with caching layers which presume that all browsers should see the same markup. The second will not.

Also, consider Modernizr rather than rolling your own IE 7 support.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文