0

我有一些CSS,当我的CSS文件内没有应用到我的设计师在Visual Studio中,但是当我发布它时应用到页面。这个问题是大规模放缓网站的发展,因为我试图拿起CSS,因为我去......未在Visual Studio 2012设计器中应用CSS?

下面是CSS的样本位:

.header { 
    background-color: #ccc; 
    border-bottom: 1px solid #666; 
    color: #222; 
    display: block; 
    font-size: 20px; 
    font-weight: bold; 
    padding: 100px 100px 100px 100px; 
    text-align: center; 
    text-decoration: none; 
     text-shadow: 0px 1px 0px #fff; 
    background-image: -webkit-gradient(linear, left top, left bottom, 
             from(#ccc), to(#999)); 
} 

我将页面上的CSS:

<header> 
    <asp:Label ID="lblQuestion" runat="server" Font-Bold="True" Font-Size="16pt" Text="Your question goes here..." CssClass="header"></asp:Label> 
</header> 

我加入CSS页面:

<link rel="stylesheet" type="text/css" href="mycss.css" media="only screen and (max-width: 480px)" /> 

我很新的CSS,所以我希望有人能告诉我我在干什么,这就是停止Visual Studio在设计器中正确渲染CSS ...

另外,如果我直接在页面中放置CSS标签,那么它可以工作,但我宁愿让我的CSS放在它自己的文件中,它可以被重用。

例作风工作:

<style> 
    .header { 
     background-color: #ccc; 
     border-bottom: 1px solid #666; 
     color: #222; 
     display: block; 
     font-size: 20px; 
     font-weight: bold; 
     padding: 100px 100px 100px 100px; 
     text-align: center; 
     text-decoration: none; 
     text-shadow: 0px 1px 0px #fff; 
     background-image: -webkit-gradient(linear, left top, left bottom, from(#ccc), to(#999)); 
    } 
</style> 

感谢

回答

1

我建议采取看看杰夫·威德默的博客文章,Why does Visual Studio not resolve my CSS class names?

基本上,网站相对路径的不被Visual Studio的支持。这也是为什么intellisense不能用于JavaScript的原因。

他提供了一个修复此问题:

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

UPDATE:

这里的问题是对CSS的链接标签的媒体元素。它不会出现VS知道该标签是什么,因此不会尝试解析网址。

在这种情况下,css文件与页面位于同一个文件夹中,因此它可以工作。但是,如果将css文件移动到另一个文件夹中,那么它将停止工作,上述修复将解决该问题。

+0

我实际上必须删除“media =”唯一的屏幕和(max-width:480px)“”我的链接样式表的一部分。如果你更新你的答案来解释这一点,那么这段文字就会检查屏幕尺寸并启用一个基于此的样式表,然后我可以将你标记为答案:) – Faraday

+1

@Vijay〜这是一个完全不同的问题。 – Tyanna

+0

这不是问题。这是我告诉你什么解决了我的问题(答案),并说如果你愿意解释这个问题,让其他人可以找到它,我会给你点。如果不是这样很好,我可以做出答案并将其标记为答案,只是认为我会很好...... Visual Studio 2012可以解决我的类名,并且网站相对路径在2012年可以在设计器中工作(不确定关于<2012年),我的IDE工作正常。这只是“媒体”这个问题。你的电话,我明天会回来,如果没有你的编辑我会做出回答:) – Faraday

相关问题