Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS未在Visual Studio 2012设计器中应用?_Css_Visual Studio 2010_Visual Studio_Visual Studio 2012_Designer - Fatal编程技术网

CSS未在Visual Studio 2012设计器中应用?

CSS未在Visual Studio 2012设计器中应用?,css,visual-studio-2010,visual-studio,visual-studio-2012,designer,Css,Visual Studio 2010,Visual Studio,Visual Studio 2012,Designer,我有一些css,在我的css文件中,它不会应用于VisualStudio中的设计器,而是在发布页面时应用于页面。这个问题大大减慢了网站的开发速度,因为我正在努力学习CSS 下面是CSS的一个示例: .header { background-color: #ccc; border-bottom: 1px solid #666; color: #222; display: block; font-size: 20px; font-weight: bol

我有一些css,在我的css文件中,它不会应用于VisualStudio中的设计器,而是在发布页面时应用于页面。这个问题大大减慢了网站的开发速度,因为我正在努力学习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>
<link rel="stylesheet" type="text/css" href="mycss.css" media="only screen and (max-width: 480px)" />

我正在将CSS添加到页面:

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

.标题{
背景色:#ccc;
边框底部:1px实心#666;
颜色:#222;
显示:块;
字体大小:20px;
字体大小:粗体;
填充:100px 100px 100px 100px;
文本对齐:居中;
文字装饰:无;
文本阴影:0px 1px 0px#fff;
背景图像:-webkit渐变(线性、左上、左下、从(#ccc)到(#999));
}

谢谢

我建议看一看杰夫·维德默的博文

基本上,VisualStudio不支持站点相对路径。这与intellisense不适用于javascript的原因相同

他为这个问题提供了一个解决方案:

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

更新:

这里的问题是css链接标记中的媒体元素。VS似乎不知道该标记是什么,因此不会尝试解析url


在本例中,css文件与页面位于同一文件夹中,因此它可以工作。但是,如果css文件被移动到另一个文件夹,那么它将停止工作,上面的修复程序将解决这个问题。

实际上,我必须删除指向样式表的链接中的“media=”only screen and(max width:480px)”部分。如果你更新你的答案来解释这一点,那一段文字会检查屏幕大小并基于此启用样式表,那么我可以将你标记为答案:)@Vijay~这是一个完全不同的问题。这不是问题。这就是我告诉你是什么解决了我的问题(答案),并说如果你愿意解释这个问题以便其他人可以找到它,我会给你分数。如果不是,那很好,我可以做一个答案并把它标记为答案,只是觉得我会很好。。。Visual Studio 2012会解析我的类名,而站点相对路径在2012年的设计器中也会起作用(不确定@Vijay~我猜VS不知道媒体元素。因此,它不会尝试解析路径。如果没有路径,它对您有效的原因是b/c css文件与您的页面位于同一文件夹中。通常您会将其放在自己的css或媒体文件夹中。@Vijay~请尝试在css中定义媒体: