MVC 中仅 IE7 样式表
我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的两个选择会做完全不同的事情。第一个,
[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.