为什么Visual Studio不能解析我的CSS类名? [英] Why does Visual Studio not resolve my CSS class names?

查看:138
本文介绍了为什么Visual Studio不能解析我的CSS类名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我在Visual Studio中工作时,我总是发现它不会解决我的html中的CSS类名。 CSS类名称将在Visual Studio中显示为绿色波浪线,但是当在浏览器中查看时,该页面将呈现正常。所以我知道css文件在我的主页正确引用,但Visual Studio只是无法解决它。设计视图也不会显示任何CSS样式。

Whenever I am working in Visual Studio I always found that it will not resolve the css class names in my html. The CSS Class names will appear with the green squiggly line in Visual Studio but then the page will render fine when viewing it in the browser. So I know the css file is referenced correctly in my master page but Visual Studio is just failing to resolve it. Also the Design View will not show any of the css styles either.

推荐答案

查看Jeff King的这篇文章,能够找到具有intellisense的javascript文件: JScript IntelliSense常见问题

See this post by Jeff King about getting Visual Studio to be able to find the javascript file with the intellisense: JScript IntelliSense FAQ.

特别的读点#4,第三个项目符号:

In particular read point #4, third bullet:


路径 - 这些是/ folder / file形式的路径
,并且是
从您的站点的基础计算
http:// site / application / folder / file )。
此方法受ASP.NET
Web窗体和ASP.NET MVC的支持。但是,
它不支持Visual Studio。
原因是因为Visual Studio
并不总是知道您的网站的最终
部署位置和
因此路径解析不能
保证。考虑到我们已经
看到少数人使用网站相关的
路径,我们可以考虑做一个
假设只是解决这种类型的
路径到项目的根。
考虑到你可能认为你的
网站正在工作的风险,当它真的不是,
我想看看有多少人是
支持这一点。

Site-Relative Paths - These are paths of the form "/folder/file", and is calculated from the base of your site (http://site/application/folder/file). This approach is supported by ASP.NET Web Forms and ASP.NET MVC. However, it is not supported by Visual Studio. The reason is because Visual Studio does not always know the final deployed location of your site and thus the path resolution cannot be guaranteed. Given that quite we've seen few folks are using site-relative paths, we could consider making an assumption just resolving this type of path to the root of the project. Given the risk that you may think your site is working when it's really not, I wanted to see how many people were supportive of this.

请注意[Site-Relative Paths are]不受Visual Studio支持。我总是使用我的javascript和css文件的网站相对路径,所以解决方案让Visual Studio找到你的javascript文件是同样的解决方案,让Visual Studio找到你的CSS文件:

Notice the "[Site-Relative Paths are] NOT supported by Visual Studio". I always use site relative paths for my javascript and css files so the solution to get Visual Studio to find your javascript files is the same solution to get Visual Studio to find your css files:

<link href="/content/default.css" rel="stylesheet" type="text/css" />
<% if (false) {%>
    <link href="../../content/default.css" rel="stylesheet" type="text/css" />
<% } %>



现在Visual Studio可以找到CSS文件并验证我的CSS类名存在

And now Visual Studio can find the CSS file and validate my CSS Class names exist (and Design View looks so much better too).

在我的博客上发布:
为什么Visual Studio不能解析我的CSS类名称?

Posted on my blog here: Why does Visual Studio not resolve my CSS class names?

-Jeff

这篇关于为什么Visual Studio不能解析我的CSS类名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆