CSS not being applied in Visual Studio 2012 designer?

前端 未结 1 836
小蘑菇
小蘑菇 2021-01-28 07:19

I have some css, which when inside my CSS file isn\'t applied to my designer in Visual Studio, but is applied to the page when I publish it. This issue is slowing down site dev

相关标签:
1条回答
  • 2021-01-28 08:01

    I suggest taking a look at Jeff Widmer's blog post, Why does Visual Studio not resolve my CSS class names?

    Basically, site relative path's aren't supported by Visual Studio. It is the same reason why intellisense doesn't work for javascript.

    He offers a fix for this issue:

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

    UPDATE:

    The problem here was the media element in the link tag for the css. It doesn't appear that VS knows what that tag is and thus doesn't try to resolve the url.

    In this case, the css file is in the same folder as the page, so it would work. But, if the css file is moved into another folder, then it would stop working and the fix above would solve the issue.

    0 讨论(0)
提交回复
热议问题